Repository navigation
Conversation
There is no need to set PySetObject explicitly to 0/NULL, since _PyType_AllocNoTrack() already initialize memory to zeros.
eendebakpt
approved these changes
Nov 2, 2026
eendebakpt
left a comment
Contributor
There was a problem hiding this comment.
Changes are correct. I checked and the compiler does not optimize it away (because type is not compile time), so this is a minor optimization. Did you do benchmarks victor?
I am wondering if we should do this more (there are dozens of sites in cpython where this can be done, some hot paths are enumerate and BaseException_new).
|
|
||
| so = (PySetObject *)_PyType_AllocNoTrack(type, 0); | ||
| if (so == NULL) | ||
| // Initialize PySetObject members to 0/NULL |
Contributor
There was a problem hiding this comment.
Suggested change
| // Initialize PySetObject members to 0/NULL | |
| // fields are zero-initialized by _PyType_AllocNoTrack |
(or leave the comment out)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There is no need to set PySetObject explicitly to 0/NULL, since _PyType_AllocNoTrack() already initialize memory to zeros.
PyFrozenWriterC API to create afrozensetobject #160147