summaryrefslogtreecommitdiffstatshomepage
path: root/py/builtinhelp.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-10-22 01:06:34 +1100
committerDamien George <damien.p.george@gmail.com>2019-10-22 15:30:52 +1100
commitd2384efa809953152c57cbda4c339dfbaa64cf29 (patch)
tree516c43255888552e751d63986841a9e99772f23b /py/builtinhelp.c
parent9c5262f25ef29950da241380c76e035b3a8cec38 (diff)
downloadmicropython-d2384efa809953152c57cbda4c339dfbaa64cf29.tar.gz
micropython-d2384efa809953152c57cbda4c339dfbaa64cf29.zip
py: Automatically provide weak links from "foo" to "ufoo" module name.
This commit implements automatic module weak links for all built-in modules, by searching for "ufoo" in the built-in module list if "foo" cannot be found. This means that all modules named "ufoo" are always available as "foo". Also, a port can no longer add any other weak links, which makes strict the definition of a weak link. It saves some code size (about 100-200 bytes) on ports that previously had lots of weak links. Some changes from the previous behaviour: - It doesn't intern the non-u module names (eg "foo" is not interned), which saves code size, but will mean that "import foo" creates a new qstr (namely "foo") in RAM (unless the importing module is frozen). - help('modules') no longer lists non-u module names, only the u-variants; this reduces duplication in the help listing. Weak links are effectively the same as having a set of symbolic links on the filesystem that is searched last. So an "import foo" will search built-in modules first, then all paths in sys.path, then weak links last, importing "ufoo" if it exists. Thus a file called "foo.py" somewhere in sys.path will still have precedence over the weak link of "foo" to "ufoo". See issues: #1740, #4449, #5229, #5241.
Diffstat (limited to 'py/builtinhelp.c')
-rw-r--r--py/builtinhelp.c4
1 files changed, 0 insertions, 4 deletions
diff --git a/py/builtinhelp.c b/py/builtinhelp.c
index a7fede00ac..8f162d8858 100644
--- a/py/builtinhelp.c
+++ b/py/builtinhelp.c
@@ -80,10 +80,6 @@ STATIC void mp_help_print_modules(void) {
mp_help_add_from_map(list, &mp_builtin_module_map);
- #if MICROPY_MODULE_WEAK_LINKS
- mp_help_add_from_map(list, &mp_builtin_module_weak_links_map);
- #endif
-
#if MICROPY_MODULE_FROZEN_STR
extern const char mp_frozen_str_names[];
mp_help_add_from_names(list, mp_frozen_str_names);