-
-
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
Use Py_NewRef & Py_XNewRef where applicable #86453
Comments
Following https://bugs.python.org/issue42262, I think it'd be nice to convert existing C code to use the more concise Py_NewRef() and Py_XNewRef() where possible. Increases readability and less bug prone. Opening this new issue to track the conversion. |
In general, we don't accept changes which are only coding style changes. I don't see how Py_NewRef() or Py_XNewRef() is less error prone. In my experience, any change is more likely to introduce new bugs than leaving the code unchanged. See #23170 for a concrete case of a PR which converts code to Py_NewRef() / Py_XNewRef(): the PR introduced bugs (in early versions of the PR). |
Agree that inserting changes opens a door to introducing bugs. However, the "end state" of having Py_NewRef() is desired, I think. It is more concise. It is less error prone because where you use it, you literally can't miss the "increment refcount" part when stealing a reference from another source. Py_INCREF has to come before/after stealing a ref, leaving room for error, IMHO.
Didn't know that. Well if that's the case, then obviously there is no reason to work specifically on this conversion. |
If people want to use Py_NewRef(), I suggest to do while modifying the code for another reason. But not propose PRs just to use Py_NewRef(). |
Superseded by #99300 |
Well, I change my mind since 2020 :-) I used Py_NewRef() in more and more code and now I can see that it makes the code easier to understand and easier to maintain. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: