Skip to content

core: Enable some features neede for a port of python3's decimal module #3377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 8, 2020

Conversation

jepler
Copy link

@jepler jepler commented Sep 6, 2020

bit_length and 3-arg pow() are needed for a reduced port I'm making of desktop Python's Decimal library. Enable them everywhere we want a FULL_BUILD.

The added code is +100 bytes for int.bit_length() and +476 bytes for 3-arg pow(). It would be possible to eliminate the use of 3-arg pow() from jepler_udecimal (decimal has had its 3-arg-pow support removed, but there's one other calculation that makes use of 3-arg pow of regulat integers), but eliminating .bit_length() is infeasible.

The jepler_udecimal package is at https://jepler-udecimal.readthedocs.io/en/latest/

Incidentally, it took about 51kB to load this work-in-progress code on an nrf52840 based board:

>>> gc.collect(); gc.mem_free()
138912
>>> import udecimal
>>> gc.collect(); gc.mem_free()
87584
>>> 138912-87584
51328

This method of integer objects is needed for a port of python3's
decimal.py module.

MICROPY_CPYTHON_COMPAT is enabled by CIRCUITPY_FULL_BUILD.
This is needed for a port of python3's decimal.py module.
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@tannewt tannewt merged commit bbd8029 into adafruit:main Sep 8, 2020
@jepler
Copy link
Author

jepler commented Sep 8, 2020

thank you!

@jepler jepler deleted the support-udecimal branch November 3, 2021 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants