-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
gh-140824: Implement the math package in Python #141363
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
base: main
Are you sure you want to change the base?
Conversation
Rename the 'math' extension to '_math'.
| # gh-140824: Fix module name for pickle | ||
| def patch_module(objs, module): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better just to have the module name as math.integer for these functions in C?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In C, function.__module__ is set to the extension name: so set to _math or _math_integer. The whole purpose of this PR is to fix function.__module__.
|
When you're done making the requested changes, leave the comment: |
Co-authored-by: Adam Turner <[email protected]>
|
@AA-Turner: I addressed your review. Please review the updated PR. |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still a hack. I think there should be more straightforward way.
| from _math_integer import comb, factorial, gcd, isqrt, lcm, perm | ||
| patch_module([comb, factorial, gcd, isqrt, lcm, perm], 'math.integer') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe then instead:
import _math_integer
patch_module(_math_integer, 'math.integer')where in the patch_module() you will fix all public names in the submodule namespace?
This still be a hack, but at least we can factor out patch_module() to some helper function, that can be used when a new submodule will be added to the stdlib.
|
I believe there is a way to do this without hacks. |
Rename the 'math' extension to '_math'.