BigEd / python-on-a-chip

Automatically exported from code.google.com/p/python-on-a-chip
Other
1 stars 3 forks source link

Add support for platform-specific module loading #234

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Enable support for pep-302 (http://www.python.org/dev/peps/pep-0302/). This 
would allow to the user to define were he wants to import aditional modules, 
for example having a minimal set of code on the compiled image and later 
importing the rest of the app from a ramdisk or waiting from a serial 
connection (something like booting Linux with NetBoot or PXE) or whatever other 
way.

Original issue reported on code.google.com by piranna on 15 Apr 2012 at 11:56

GoogleCodeExporter commented 9 years ago
What do you think about this alternative that attempts to solve the same 
problem:
1) Define a plat_modImport() function that is an optional part of the 
platform-porting interface.  The platform-programmer creates the function and 
registers it by calling a new function: mod_registerPlatImportCallback().
2) I modify mod_import() to test if a callback has been registered, if so call 
it *first* before pm_global_module_table is searched.  This way, a 
platform-programmer can override a module that is defined by the p14p builtins. 
 (In this case, the "override" happens because the platform modules are 
searched and found first)

I think the benefits of this method are that (1) the VM (shared by all 
platforms) retains simplicity and the complexity of searching other places for 
modules is added to the platform and (2) my method is more lightweight than an 
implementation of PEP-302.

Original comment by dwhall...@gmail.com on 8 May 2012 at 3:48

GoogleCodeExporter commented 9 years ago
Interesting idea, essentially it has the same purpose that PEP-302 being far 
simple :-D Only that instead of add the custom imports at Python side you do it 
at virtual machine level. Ok, i like it :-) Maybe one can develop a full 
PEP-302 implementation inside this plat_modImport() function... :-P

Another interesting thing is that since this would allow to override p14p 
builtins modules, they could be added easily version more compatibles with 
standard lib having inside PyMite just the minimal ones to boot :-)

Original comment by piranna on 8 May 2012 at 4:40

GoogleCodeExporter commented 9 years ago

Original comment by dwhall...@gmail.com on 8 May 2012 at 5:57

GoogleCodeExporter commented 9 years ago
This issue was closed by revision ce34afb80c1a.

Original comment by dwhall...@gmail.com on 16 May 2012 at 3:53

GoogleCodeExporter commented 9 years ago
This implementation is for the v10 branch.
Similar work could be done for the r09 branch, but would have to use code 
images instead of marshalled code objects.

Original comment by dwhall...@gmail.com on 16 May 2012 at 3:55

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 93ef157dd8f4.

Original comment by dwhall...@gmail.com on 20 May 2012 at 3:33