Skip to content
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

gh-90716: add _pylong.py module #96673

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

nascheme
Copy link
Member

@nascheme nascheme commented Sep 8, 2022

Add Python implementations of certain longobject.c functions. These use smarter algorithms and can be much faster on large numbers. Currently implemented is long_to_decimal_string() (based on code from Tim) and divmod_fast() (based on code from Mark). The longobject.c module has been changed to call into _pylong if the Python version is likely to be faster.

Note: This is a work-in-progress. Needs cleanup, unit tests, etc.

Co-author: Tim Peters tim.peters@gmail.com
Co-author: Mark Dickinson dickinsm@gmail.com

Add Python implementations of certain longobject.c algorithms. These can
be much faster on large numbers.

Co-author: Tim Peters <tim.peters@gmail.com>
Co-author: Mark Dickinson <dickinsm@gmail.com>
@nascheme nascheme added type-feature A feature request or enhancement DO-NOT-MERGE labels Sep 8, 2022
@nascheme
Copy link
Member Author

nascheme commented Sep 8, 2022

Some relevant discussion on the pros and cons of adding these "smarter" but more complicated algorithms:

https://discuss.python.org/t/faster-large-integer-multiplication/13300

I think implementing them in Python lowers the bar quite a bit in terms of what is maintainable in the long term. We have a small number of core devs who are numeric experts so we need to be cautious about adding a bunch of complex code. Maybe this PR already goes too far? It feels like pretty good "bang for buck" to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants