Repository navigation
GH-155728: Untrack const tuples #156419
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?
GH-155728: Untrack const tuples #156419
Changes from all commits
ce997c2
5064e61
cbf8fed
fee31fe
ff42c31
b2b039c
234af7d
fda2780
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| The flowgraph optimizer now untracks tuples from the GC when possible. Patch | ||
| by Sergey Miryanov. | ||
|
Comment on lines
+1
to
+2
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's also mention the changes in |
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -593,7 +593,10 @@ _PyTuple_Concat(PyObject *aa, PyObject *bb) | |||||||
| dest[i] = Py_NewRef(v); | ||||||||
| } | ||||||||
|
|
||||||||
| _PyObject_GC_TRACK(np); | ||||||||
| if (_PyObject_GC_IS_TRACKED(aa) || _PyObject_GC_IS_TRACKED(bb)) | ||||||||
| { | ||||||||
|
Comment on lines
+596
to
+597
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I suppose we can't use |
||||||||
| _PyObject_GC_TRACK(np); | ||||||||
| } | ||||||||
| return (PyObject *)np; | ||||||||
| } | ||||||||
|
|
||||||||
|
|
@@ -642,7 +645,10 @@ _PyTuple_Repeat(PyObject *self, Py_ssize_t n) | |||||||
| _Py_memory_repeat((char *)np->ob_item, sizeof(PyObject *)*output_size, | ||||||||
| sizeof(PyObject *)*input_size); | ||||||||
| } | ||||||||
| _PyObject_GC_TRACK(np); | ||||||||
| if (_PyObject_GC_IS_TRACKED(self)) | ||||||||
| { | ||||||||
|
Comment on lines
+648
to
+649
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Same here |
||||||||
| _PyObject_GC_TRACK(np); | ||||||||
| } | ||||||||
| return (PyObject *) np; | ||||||||
| } | ||||||||
|
|
||||||||
|
|
||||||||
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.
Add a test for subclasses, please
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.
Not sure actually whether Python-level subclass would catch this kind of bug (those probably are always tracked?)
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.
Yeah it seems that Python-level tuple subclasses are always tracked by
PyType_GenericAlloc. It has to be a struct sequence created viaPyStruct_SequenceNew(which doesn't track), something like this: