You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add support for using a btree database (DefinesDB) to store defines for preprocessing
The btree module, which ships with MicroPython, can efficiency manage a large
number of key-value pairs with minimal memory. It automatically initialises
to appropriate memory and cache limits, based on the device it's running
on, but if needed those parameters can be tuned too, e.g. to restrict memory
usage further.
The database is optional and must be supplied to the Preprocessor via the
use_db() method. It's safe however to always supply it, because a non-existing
database will behave like an empty database.
Care is taken not to unnecessarily create an empty db, when only reading from it
and not to unnecessarily check the file-system whether the database exists.
Inside the Preprocessor the database is opened and closed with a context manager.
This ensures the database will be closed properly again. While DefinesDB opens
the underlying database automatically, it cannot automatically close the database
again (using a destructor __del__ does not work, and MicroPython does not have
the "atexit" exit handler on the esp32). By using a context manager, the code
becomes cleaner, while still ensuring the database is closed at the end.
0 commit comments