micropython/ports
Paul Sokolovsky e7fc765880 unix/mpconfigport: Disable uio.resource_stream().
This function was implemented as an experiment, and was enabled only in
unix port. To remind, it allows to access arbitrary files frozen as
source modules (vs bytecode).

However, further experimentation showed that the same functionality can
be implemented with frozen bytecode. The process requires more steps, but
with suitable toolset it doesn't matter patch. This process is:

1. Convert binary files into "Python resource module" with
tools/mpy_bin2res.py.
2. Freeze as the bytecode.
3. Use micropython-lib's pkg_resources.resource_stream() to access it.

In other words, the extra step is using tools/mpy_bin2res.py (because
there would be wrapper for uio.resource_stream() anyway).

Going frozen bytecode route allows more flexibility, and same/additional
efficiency:

1. Frozen source support can be disabled altogether for additional code
savings.
2. Resources could be also accessed as a buffer, not just as a stream.

There're few caveats too:

1. It wasn't actually profiled the overhead of storing a resource in
"Python resource module" vs storing it directly, but it's assumed that
overhead is small.
2. The "efficiency" claim above applies to the case when resource
file is frozen as the bytecode. If it's not, it actually will take a
lot of RAM on loading. But in this case, the resource file should not
be used (i.e. generated) in the first place, and micropython-lib's
pkg_resources.resource_stream() implementation has the appropriate
fallback to read the raw files instead. This still poses some distribution
issues, e.g. to deployable to baremetal ports (which almost certainly
would require freezeing as the bytecode), a distribution package should
include the resource module. But for non-freezing deployment, presense
of resource module will lead to memory inefficiency.

All the discussion above reminds why uio.resource_stream() was implemented
in the first place - to address some of the issues above. However, since
then, frozen bytecode approach seems to prevail, so, while there're still
some issues to address with it, this change is being made.

This change saves 488 bytes for the unix x86_64 port.
2017-12-10 02:38:23 +02:00
..
bare-arm all: Remove inclusion of internal py header files. 2017-10-04 12:37:50 +11:00
cc3200 py/objstr: Remove "make_qstr_if_not_already" arg from mp_obj_new_str. 2017-11-16 13:17:51 +11:00
esp8266 esp8266/modnetwork: Make sure to intern string passed to .config("param"). 2017-12-04 00:13:10 +02:00
minimal py/persistentcode: Bump .mpy version number to version 3. 2017-10-05 10:49:44 +11:00
pic16bit all: Update Makefiles and others to build with new ports/ dir layout. 2017-09-06 14:09:13 +10:00
qemu-arm lib/tinytest: Move from tools/tinytest. 2017-12-08 19:26:15 +02:00
stm32 stm32/boards/*_af.csv: Make consistent use of JTMS, JTCK, SWDIO, SWCLK. 2017-12-01 14:51:36 +11:00
teensy teensy: Get port compiling without any warnings. 2017-11-01 11:00:30 +11:00
unix unix/mpconfigport: Disable uio.resource_stream(). 2017-12-10 02:38:23 +02:00
windows all: Update Makefiles and others to build with new ports/ dir layout. 2017-09-06 14:09:13 +10:00
zephyr zephyr/main: Move var declarations to the top of file. 2017-12-08 12:39:57 +02:00