Relationship between micropython and micropython-lib projects?

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
User avatar
ccooper21
Posts: 3
Joined: Sun Aug 13, 2017 8:27 am

Relationship between micropython and micropython-lib projects?

Post by ccooper21 » Sun Aug 13, 2017 8:31 am

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

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Relationship between micropython and micropython-lib projects?

Post by pfalcon » Mon Aug 28, 2017 8:05 am

Did you try to read the docs for both projects, among them:
I may imagine that after reading these docs there may be some questions, but not as generic as "What's the relationship between micropython and micropython-lib"
The "micropython/utime" module provides an implementation for the "localtime(...)" function in native code. However, the "time" module precedes to redefine the "localtime(...)"
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.
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/

Post Reply