You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When starting the REPL, everything in the pybricks package is supposed to be pre-imported.
This no longer works because:
for (size_ti=0; i<MP_ARRAY_SIZE(pybricks_globals_table); i++) {
mp_rom_obj_tmodule=pybricks_globals_table[i].value;
if (mp_obj_is_type(module, &mp_type_module)) {
// Import everything from the module.mp_import_all((mp_obj_t)module);
}
}
and the modules are no longer included in pybricks_globals_table.
While we are doing this, we could consider importing everything, including those from MicroPython modules. I'll have a look at the RAM cost
On Prime Hub, when importing everything:
stack: 604 out of 36976
GC: total: 259008, used: 2272, free: 256736
No. of 1-blocks: 14, 2-blocks: 3, max blk sz: 112, max free sz: 15915
When importing only pybricks modules (+36 bytes build size for the check):
stack: 604 out of 36976
GC: total: 259008, used: 1008, free: 258000
No. of 1-blocks: 20, 2-blocks: 4, max blk sz: 19, max free sz: 16116
So, about 1.2K extra heap used for importing everything from the (currently included) MicroPython modules.
Now check on Move Hub. Oh wait, no REPL. 😆
So I think we can just import everything. If anyone ever needs the REPL and use RAM to the limits, they can just run an empty script that raises the KeyboardInterrupt.
Are we sure that there are and never will be name conflicts for importing * from *? It seems like it would be safer to import * from pybricks modules but import module for everything else.
mp_import_name and several other related calls just fetch the module but don't register it as loaded. Simply doing it like pybricks/pybricks-micropython@7b57a7a works though.
Activity
laurensvalk commentedon Oct 20, 2022
While we are doing this, we could consider importing everything, including those from MicroPython modules. I'll have a look at the RAM cost.
laurensvalk commentedon Oct 20, 2022
On Prime Hub, when importing everything:
When importing only pybricks modules (+36 bytes build size for the check):
So, about 1.2K extra heap used for importing everything from the (currently included) MicroPython modules.
Now check on Move Hub. Oh wait, no REPL. 😆
So I think we can just import everything. If anyone ever needs the REPL and use RAM to the limits, they can just run an empty script that raises the KeyboardInterrupt.
pybricks/pybricks: Fix auto-import in REPL.
dlech commentedon Oct 20, 2022
Are we sure that there are and never will be name conflicts for importing * from *? It seems like it would be safer to import * from pybricks modules but import module for everything else.
laurensvalk commentedon Oct 20, 2022
OK, I'll restore importing Pybricks modules only.
dlech commentedon Oct 20, 2022
I like the idea of importing the other modules too. Maybe we could import * if module starts with pybricks else import module?
laurensvalk commentedon Oct 20, 2022
Sure. Will do that tomorrow.
laurensvalk commentedon Oct 20, 2022
mp_import_nameand several other related calls just fetch the module but don't register it as loaded. Simply doing it like pybricks/pybricks-micropython@7b57a7a works though.dlech commentedon Oct 21, 2022
can this be closed now?
laurensvalk commentedon Oct 21, 2022
Yes.