Skip to content

Commit

Permalink
py/builtinimport: Refactor module importing.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jimmo authored and dpgeorge committed Dec 1, 2021
1 parent 851ecb2 commit a7fa18c
Show file tree
Hide file tree
Showing 6 changed files with 341 additions and 250 deletions.
1 change: 1 addition & 0 deletions ports/unix/mpconfigport.h
Expand Up @@ -86,6 +86,7 @@
#define MICROPY_OPT_MAP_LOOKUP_CACHE (1)
#endif
#define MICROPY_MODULE_WEAK_LINKS (1)
#define MICROPY_MODULE_OVERRIDE_MAIN_IMPORT (1)
#define MICROPY_CAN_OVERRIDE_BUILTINS (1)
#define MICROPY_VFS_POSIX_FILE (1)
#define MICROPY_PY_FUNCTION_ATTRS (1)
Expand Down
1 change: 1 addition & 0 deletions ports/windows/mpconfigport.h
Expand Up @@ -60,6 +60,7 @@
#define MICROPY_STREAMS_POSIX_API (1)
#define MICROPY_OPT_COMPUTED_GOTO (0)
#define MICROPY_MODULE_WEAK_LINKS (1)
#define MICROPY_MODULE_OVERRIDE_MAIN_IMPORT (1)
#define MICROPY_CAN_OVERRIDE_BUILTINS (1)
#define MICROPY_VFS_POSIX_FILE (1)
#define MICROPY_PY_FUNCTION_ATTRS (1)
Expand Down

0 comments on commit a7fa18c

Please sign in to comment.