-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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-103906: Remove immortal refcounting in compile/marshal.c #103922
Conversation
corona10
commented
Apr 27, 2023
•
edited by bedevere-bot
Loading
edited by bedevere-bot
- Issue: Avoid reference counting operations on None, True, False in the interpreter #103906
@brandtbucher Not sure worth to do it at compile.c as much as an interpreter but it looks possible. |
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.
If you grep for Py_NewRef(Py_Ellipsis)
there are a few more in other files, though I doubt it will make a measurable difference in performance.
Co-authored-by: Jelle Zijlstra <[email protected]>
I'm a bit concerned that a change like this would make it hard to reverse the decision to make these objects immortal in the future (it is no longer clear where we need a new reference and where we don't). Should we have Py_New_None/Py_New_Elipsis/etc macros instead, so that the code is clear about this? |
I think that it will be the proper way and easy to track. |
I'm not sure that will be workable. Since there is no refcount change, there will be no way to enforce that these macros are used correctly, so we're likely to regress very quickly on correct use of those macros. |
@vstinner What do you think about this agenda? |
True. We would need a test mode where they are not immortal and the macros actually change the refcount. |
I am not sure that I understand your intention correctly, so do we need to introduce the following configuration things? |
Yes, we'd need something like that. We'd have to run at least one buildbot under that configuration mode too. I'm honestly not sure it would be worth introducing that much complexity. |
One of my concerns about adding such a configuration which determining the C API or macro behavior, as @JelleZijlstra commented it should always be run under at least from the build bot with the configuration enabled. Without the integration from the CI level, such configuration is easily broken and can not guarantee to be built successfully at any time. This is one of my lessons from the |
My suggestion: |
We need a decision on whether we want to put some effort into making the move immortality reversible, or not. The technicalities are not very difficult once that decision is made. I'm not sure who should make the call, but it's not me. |
The SC approved https://peps.python.org/pep-0683/ Why would be move backward and remove immortal objects? I'm not used to immortal objects, so right now I'm surprised that some objects require Py_NewRef() whereas others don't. It makes the code less regular and so harder to review for me. But I prefer to stay outside this topic and let others review it :-) |
It looks like #105195 will be merged soon. I merge this PR, please let me know if the PR occurs any problem. |