diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-01-20 00:03:34 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-01-20 00:38:39 +0200 |
commit | d720ab5236015124a13c09175ed674e565414faa (patch) | |
tree | 201a5cca563eaad2e76651add86b8dc4de923c1a /py/obj.h | |
parent | f438b936e0edcbc3eab9af6cc3513db1f01ab17e (diff) | |
download | micropython-d720ab5236015124a13c09175ed674e565414faa.tar.gz micropython-d720ab5236015124a13c09175ed674e565414faa.zip |
Implement modules as singletons Python semantics.
In Python, importing module several times returns same underlying module
object. This also fixes import statement handling for builtin modules.
There're still issues:
1. CPython exposes set of loaded modules as sys.modules, we may want to
do that either.
2. Builtin modules are implicitly imported, which is not really correct.
We should separate registering a (builtin) module and importing a module.
CPython keeps builtin module names in sys.builtin_module_names .
Diffstat (limited to 'py/obj.h')
-rw-r--r-- | py/obj.h | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -356,6 +356,7 @@ extern const mp_obj_type_t gen_instance_type; // module extern const mp_obj_type_t module_type; mp_obj_t mp_obj_new_module(qstr module_name); +mp_obj_t mp_obj_module_get(qstr module_name); struct _mp_map_t *mp_obj_module_get_globals(mp_obj_t self_in); // staticmethod and classmethod types; defined here so we can make const versions |