As I dig deeper into the micropython and micropython-lib projects, I realize that I have some confusion about the relationship between the two. Specifically, I have encountered several cases where the two are wired together in a peculiar way, or at least a potentially suboptimal way.
Here are two examples:
- The "micropython-lib/base64" module imports the "micropython-lib/binascii" and "micropython-lib/struct" modules. In my experimentation, the "base64" module seems to work fine if I just import the "micropython/ubinascii" and "micropython/ustruct" modules and alias them accordingly. If the latter works, wouldn't it make more sense to do so, as it would reduce the amount of code that needs to be loaded onto a device and reduce the run-time memory footprint? Hopefully, the native code performance would be better as well.
- The "micropython-lib/time" module imports all of the names from the "micropython/utime" module (i.e. it has a "from utime import *" statement). The "micropython/utime" module provides an implementation for the "localtime(...)" function in native code. However, the "time" module precedes to redefine the "localtime(...)" function in Python, without any apparent functional difference. The only reason I can see this making sense is that the "time" module also implements the related "gmtime(...)" function, which is not available via the "utime" module, hence both are implemented in a similar fashion. I'm not sure this really makes sense though given the goal to be extremely memory efficient.
Is there an intentional pattern that has been applied here, or is it just not well defined how the two projects should interact?
-- Chris
Relationship between micropython and micropython-lib projects?
Re: Relationship between micropython and micropython-lib projects?
Did you try to read the docs for both projects, among them:
- https://github.com/micropython/micropyt ... /README.md
- https://github.com/micropython/micropyt ... /README.md
- http://docs.micropython.org/en/latest/p ... index.html
- http://docs.micropython.org/en/latest/p ... python-lib
This one (and similar) are even simpler - micropython-lib wasn't created by higher powers in seven days, and stays still since that. It's a work in progress, may lag behind micropython, and gets updated by real people as they discover issues. It could use more effort - just like almost any other project out there. What's important is that micropython-lib was actually useful and used by people, and then any issue will be shallow.The "micropython/utime" module provides an implementation for the "localtime(...)" function in native code. However, the "time" module precedes to redefine the "localtime(...)"
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/