diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2020-02-26 15:24:09 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2021-12-01 13:23:34 +1100 |
commit | a7fa18c203a241f670f12ab507aa8b349fcd45a1 (patch) | |
tree | 19bb7a3451e11aa6b0bc3e8a16a60c4e0ce59ab1 /py/objmodule.h | |
parent | 851ecb2da178fff0b60aefdb5af502f28787a7ec (diff) | |
download | micropython-a7fa18c203a241f670f12ab507aa8b349fcd45a1.tar.gz micropython-a7fa18c203a241f670f12ab507aa8b349fcd45a1.zip |
py/builtinimport: Refactor module importing.
Simplify and document/comment the handling of builtin import for:
- already-loaded modules
- built-in modules
- built-in umodules (formerly weak links)
- filesystem modules
Retains existing functionality with smaller code size but should also
facilitate potential new features (built-in packages, controlling the
frozen path).
Also makes the (unix-only) -m behavior a bit more obvious and configurable.
Code size change with this commit:
bare-arm: +0 +0.000%
minimal x86: -64 -0.039%
unix x64: -32 -0.006%
unix nanbox: -4 -0.001%
stm32: -184 -0.047% PYBV10
cc3200: -120 -0.065%
esp8266: -228 -0.033% GENERIC
esp32: -268 -0.018% GENERIC[incl +16(data)]
nrf: -152 -0.087% pca10040
rp2: -256 -0.052% PICO
samd: -80 -0.057% ADAFRUIT_ITSYBITSY_M4_EXPRESS
Diffstat (limited to 'py/objmodule.h')
-rw-r--r-- | py/objmodule.h | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/py/objmodule.h b/py/objmodule.h index fde4fff34e..8a82d13fe5 100644 --- a/py/objmodule.h +++ b/py/objmodule.h @@ -30,18 +30,9 @@ extern const mp_map_t mp_builtin_module_map; -mp_obj_t mp_module_get(qstr module_name); -void mp_module_register(qstr qstr, mp_obj_t module); - -mp_obj_t mp_module_search_umodule(const char *module_str); - -#if MICROPY_MODULE_BUILTIN_INIT -void mp_module_call_init(qstr module_name, mp_obj_t module_obj); -#else -static inline void mp_module_call_init(qstr module_name, mp_obj_t module_obj) { - (void)module_name; - (void)module_obj; -} +mp_obj_t mp_module_get_loaded_or_builtin(qstr module_name); +#if MICROPY_MODULE_WEAK_LINKS +mp_obj_t mp_module_get_builtin(qstr module_name); #endif #endif // MICROPY_INCLUDED_PY_OBJMODULE_H |