-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Pickling objects by name without __module__ is suboptimal #122459
Labels
Comments
serhiy-storchaka
added
performance
Performance or resource usage
3.14
new features, bugs and security fixes
labels
Jul 30, 2024
serhiy-storchaka
added a commit
to serhiy-storchaka/cpython
that referenced
this issue
Jul 30, 2024
I did not expect significant effect from this change, but it make pickling a function without
This affects also pickling
The main purpose is of course cleaning up the code. |
serhiy-storchaka
added a commit
that referenced
this issue
Aug 5, 2024
brandtbucher
pushed a commit
to brandtbucher/cpython
that referenced
this issue
Aug 7, 2024
blhsing
pushed a commit
to blhsing/cpython
that referenced
this issue
Aug 22, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
When the object is pickled by name (classes, functions, and other enum-like objects) has no
__module__
attribute or it is None, the code searches the object in all imported modules: tries to resolve its name relatively to the module and check that the result is the same object.Whether the module was get from the
__module__
attribute or found insys.modules
, the code checks it again:Then it checks again: tries to resolve its name relatively to the module and check that the result is the same object.
So in some the work is repeated twice. The following PR makes it only be performed once. It also contains few other minor optimizations and simplifications.
Linked PRs
The text was updated successfully, but these errors were encountered: