mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-15 00:52:02 +00:00
feat(core): preallocate sys.modules to an appropriate size
This commit is contained in:
parent
b5c1b37a56
commit
5f4240d93c
@ -40,6 +40,7 @@
|
||||
// memory allocation policies
|
||||
#define MICROPY_ALLOC_PATH_MAX (128)
|
||||
#define MICROPY_ENABLE_PYSTACK (1)
|
||||
#define MICROPY_LOADED_MODULES_DICT_SIZE (160)
|
||||
|
||||
// emitters
|
||||
#define MICROPY_PERSISTENT_CODE_LOAD (0)
|
||||
|
@ -45,6 +45,7 @@
|
||||
#define MICROPY_MALLOC_USES_ALLOCATED_SIZE (1)
|
||||
#define MICROPY_MEM_STATS (1)
|
||||
#define MICROPY_ENABLE_PYSTACK (1)
|
||||
#define MICROPY_LOADED_MODULES_DICT_SIZE (160)
|
||||
|
||||
// emitters
|
||||
#define MICROPY_PERSISTENT_CODE_LOAD (0)
|
||||
|
@ -41,6 +41,11 @@ def unimport_begin() -> Set[str]:
|
||||
|
||||
|
||||
def unimport_end(mods: Set[str], collect: bool = True) -> None:
|
||||
# static check that the size of sys.modules never grows above value of
|
||||
# MICROPY_LOADED_MODULES_DICT_SIZE, so that the sys.modules dict is never
|
||||
# reallocated at run-time
|
||||
assert len(sys.modules) <= 160, "Please bump preallocated size in mpconfigport.h"
|
||||
|
||||
for mod in sys.modules:
|
||||
if mod not in mods:
|
||||
# remove reference from sys.modules
|
||||
|
2
vendor/micropython
vendored
2
vendor/micropython
vendored
@ -1 +1 @@
|
||||
Subproject commit 3a3068da97ee45b812db61f09af8fefd17dc80f8
|
||||
Subproject commit f7e780ae16bc62519e6b78672e43ecae9138ed0a
|
Loading…
Reference in New Issue
Block a user