micropython / micropython-lib

Core Python libraries ported to MicroPython
Other
2.3k stars 981 forks source link

Add functools.total_ordering #818

Open winni2k opened 4 months ago

winni2k commented 4 months ago

As part of my journey to port dataclasses to micropython-lib/python-stdlib (see https://github.com/orgs/micropython/discussions/13741#discussioncomment-8579351), I needed to port functools.total_ordering first.

I have tried to follow all the contribution guidelines, but I have not tried to optimize code size as I am completely new to micropython and would not know where to start.

This code (and test code) is copied from CPython v3.7.17 in its entirety. The PSF license appears to allow for this, but please do correct me if I am wrong.

winni2k commented 3 months ago

Any chance you could review this PR @mattytrentini ?

mattytrentini commented 3 months ago

Any chance you could review this PR @mattytrentini ?

Sorry, been trying to find time to do so!

Perhaps consider adding a README.md explaining how to run the tests? Ideally in a container but even if it's just a description it would be helpful (I mean, it looks like straightforward unittest code but it should be clarified). Eventually we'd like to create Github Actions to run them continuously so if we have clear instructions it'll make that task easier.

It's also important to spell out that this code is licensed under the Python license. See the root LICENSE file that mentions MIT "unless explicitly stated otherwise". I think an entry in the README will suffice.

Otherwise, the code looks good! I'm curious about the failing unit test but I'll have to look into that another time...

(PS thanks for the contribution!)

winni2k commented 3 months ago

Have a look now.