correct weak module links; samd module only in m4 ports; update frozen libs#1566
Conversation
|
|
Up until your changes Ideally I would like all CPython std module names to be weak links and an underscore version being the C module. I don't think any of the C modules cover all the CPython functionality, so they all need to be extended to achieve CPython compatibility. I saw that the new PyBoard will have 512kB of RAM, so with that amount of RAM porting the standard library is really starting to make sense. When there's 1MB of RAM, the size of the standard library modules doesn't matter much anymore. It will be other bigger libraries that will use most of the RAM. |
|
FYI - json appears twice in the modules list on both the feather_m4_express and feather_nrf52840_express -- any concern with this? I built and ran this this on those boards and a pirkey - all seem to be running fine. No obvious issues |
Looks like it's added both through the |
|
@notro How is MPy doing this? Would your sort of library completion work there? Do they have the equivalent of the I'm a little concerned that listing a lot of |
|
I'm going to discuss the |
|
If you look at mp_builtin___import__ you see that as a last resort it looks at the weak links (aliases) before giving up. So if MicroPython uses I suggest we use CPython lists underscore modules as well when doing |
Did you come to any conclusion? |
|
Maybe something like this could be used to handle the standard library module aliases: #if CIRCUITPY_TIME
extern const struct _mp_obj_module_t time_module;
#define TIME_MODULE(name) { MP_OBJ_NEW_QSTR(name), (mp_obj_t)&time_module },
#else
#define TIME_MODULE(name)
#endif
#define CIRCUITPY_MODULES \
ANALOGIO_MODULE \
...
#define CIRCUITPY_STD_LIB_MODULES(prefix) \
IO_MODULE(MP_QSTR_##prefix##io) \
OS_MODULE(MP_QSTR_##prefix##os) \
RE_MODULE(MP_QSTR_##prefix##re) \
TIME_MODULE(MP_QSTR_##prefix##time) \
...
#if MICROPY_MODULE_WEAK_LINKS
#define MICROPY_PORT_BUILTIN_MODULES \
CIRCUITPY_MODULES \
CIRCUITPY_STD_LIB_MODULES(_)
#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \
CIRCUITPY_STD_LIB_MODULES()
#else
#define MICROPY_PORT_BUILTIN_MODULES \
CIRCUITPY_MODULES \
CIRCUITPY_STD_LIB_MODULES()
#endif |
|
Could we drop the modules all together that the stdlibs implement? What is your motivation for supporting them? It doesn't seem very useful because they will use a bunch of resources. |
They add functionality that's missing from the C module. For instance the time module adds these: from _time import localtime, mktime, monotonic, sleep, struct_time, time
def asctime(t=None):
...
def ctime(secs=None):
...
def gmtime(secs=None):
...
def strftime(_format, t=None):
...
Erh, CPython compatibility? |
|
I'd like to move this discussion back to a place that's more visible instead of a closed PR, maybe #1155 or a new issue. I'll start there, and try to summarize the discussion up to this point. |
ure, turn onsamdmodule only in m4 ports (was part of extmod/ure: Extend functionality #1544, then got undone by Major refactoring of mpconfig and makefiles; compile only what's used; easy on/off of modules #1554).