Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34k
gh-140232: Do not track frozenset objects with immutables#140234
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com>
sergey-miryanov commentedOct 17, 2025 • edited by efimov-mikhail
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by efimov-mikhail
Uh oh!
There was an error while loading.Please reload this page.
Maybe it is worth to change PyObject*PyFrozenSet_Alloc(PyTypeObject*type,Py_ssize_tnitems){PyObject*obj=PyType_GenericAlloc(type,nitems);if (obj==NULL) {returnNULL; }_PyFrozenSet_MaybeUntrack(obj);returnobj;} |
eendebakpt commentedOct 17, 2025
The |
Uh oh!
There was an error while loading.Please reload this page.
sergey-miryanov left a comment
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.
Code looks good to me.
…cpython into frozenset_immutable_tracking
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
vstinner commentedOct 24, 2025
Would it be possible to write tests in Python rather than in C? |
eendebakpt commentedOct 24, 2025
I tried, but it is not easy. We have to expose Line 2778 ind78d7a5
And when calling |
sergey-miryanov commentedOct 26, 2025
IIUC, if you return the first argument from pyset_add then you can test it on the python side. |
eendebakpt commentedOct 26, 2025
Ok, I gave it another try. The first attempt failed, but by using the vectorcall convention I can keep the reference count at 1 also from the Python side. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner left a comment
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.
LGTM. With one last comment :-)
Uh oh!
There was an error while loading.Please reload this page.
eendebakpt commentedJan 27, 2026
Nice. Give me one second to double check something. |
efimov-mikhail left a comment
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.
LGTM
Uh oh!
There was an error while loading.Please reload this page.
eendebakpt commentedJan 27, 2026
The PR is ready from my side! |
sergey-miryanov left a comment
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.
Two nitpicks. Otherwise LGTM.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
08d7bd2 intopython:mainUh oh!
There was an error while loading.Please reload this page.
vstinner commentedJan 28, 2026
Merged, thanks for the many updates! |
Uh oh!
There was an error while loading.Please reload this page.
In the PR we untrack frozen tuples for the normal constructors. There are a few methods shared between the
setandfrozenset(for exampleset_intersectioninsetobject.c) where we have not added the untracking. (this is possible, but I am not sure this is worthwhile to do).Here is a small script to test the idea:
It measures the performance of garbage collection, and outputs some statistics for the numbers of frozen containers.
Main:
PR
Note: generative ai was used in creating the PR