-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com>
Maybe it is worth to change PyObject *
PyFrozenSet_Alloc(PyTypeObject *type, Py_ssize_t nitems)
{
PyObject *obj = PyType_GenericAlloc(type, nitems);
if (obj == NULL) {
return NULL;
}
_PyFrozenSet_MaybeUntrack(obj);
return obj;
} |
The |
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.
In the PR we untrack frozen tuples for the normal constructors. There are a few methods shared between the
set
andfrozenset
(for exampleset_intersection
insetobject.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