GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||
GeezerVison is showing github.com — gh-140824: Implement the math package in Python by vstinner · Pull Request #141363 · python/cpython Conversation
|
| # gh-140824: Fix module name for pickle | ||
| def patch_module(objs, module): |
There was a problem 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?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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__.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
When you're done making the requested changes, leave the comment: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Adam Turner <[email protected]>
|
@AA-Turner: I addressed your review. Please review the updated PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| 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.
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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I believe there is a way to do this without hacks. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@serhiy-storchaka dislikes this approach, so I prefer to close my PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.