feat(core): preallocate sys.modules to an appropriate size

pull/1610/head
matejcik 3 years ago committed by matejcik
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

@ -1 +1 @@
Subproject commit 3a3068da97ee45b812db61f09af8fefd17dc80f8
Subproject commit f7e780ae16bc62519e6b78672e43ecae9138ed0a
Loading…
Cancel
Save