micropython-samples/micropip
peterhinch c8aef81c5d Replace refs to PicoWeb with Microdot. Delete refs to upip and micropip. 2022-11-24 13:56:43 +00:00
..
README.md Replace refs to PicoWeb with Microdot. Delete refs to upip and micropip. 2022-11-24 13:56:43 +00:00
micropip.py Update the url of the package index at micropython.org 2020-07-28 10:13:31 +03:00

README.md

Overriding built in library modules

Some firmware builds include library modules as frozen bytecode. On occasion it may be necessary to replace such a module with an updated or modified alternative. The most RAM-efficient solution is to rebuild the firmware with the replacement implemented as frozen bytecode.

For users not wishing to recompile there is an alternative. The module search order is defined in sys.path.

>>> import sys
>>> sys.path
['', '/flash', '/flash/lib']

The '' entry indicates that frozen modules will be found before those in the filesystem. This may be overridden by issuing:

>>> import sys
>>> sys.path.append(sys.path.pop(0))

This has the following outcome:

>>> sys.path
['/flash', '/flash/lib', '']

Now modules in the filesystem will be compiled and executed in preference to those frozen as bytecode.