-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-106168: Revert the "size before item" setting #111683
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
Conversation
…d temporary inconsistencies. Also remove the "what's new" sentence regarding the size setting since tuples cannot grow after allocation.
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 the GIL, _PyList_AppendTakeRef() and list_extend() change are not important: setting the item first or setting the size first, both are safe. But when I read the code and attempt to imagine a "free threading" (NoGIL) world, yeah, I see that the Python 3.12 code looks more correct: first set the item, then announce that the list is one item longer.
Moreover I only made these 2 changes when PyList_SET_ITEM() rejected writes outside 0..size range, which is no longer the case. So I'm fine with reverting these changes.
@@ -1048,8 +1048,6 @@ New Features | |||
* If Python is built in :ref:`debug mode <debug-build>` or :option:`with | |||
assertions <--with-assertions>`, :c:func:`PyTuple_SET_ITEM` and | |||
:c:func:`PyList_SET_ITEM` now check the index argument with an assertion. | |||
If the assertion fails in :c:func:`PyTuple_SET_ITEM`, make sure that the | |||
tuple size is set before. |
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.
I was sure that I had issues with PyTuple_SET_ITEM() and code setting the tuple size just after that. But I checked again https://github.com/python/cpython/pull/106164/files and I was wrong: the problem was specific to lists, and your change (allow write into 0..allocated range) makes this sentence outdated. I'm fine with removing it.
|
|
pythongh-106168: Update the size only after setting the item, to avoid temporary inconsistencies. Also remove the "what's new" sentence regarding the size setting since tuples cannot grow after allocation.
pythongh-106168: Update the size only after setting the item, to avoid temporary inconsistencies. Also remove the "what's new" sentence regarding the size setting since tuples cannot grow after allocation.
Update the size only after setting the item, to avoid temporary inconsistencies.
Also remove the "what's new" sentence regarding the size setting since tuples cannot grow after allocation.
📚 Documentation preview 📚: https://cpython-previews--111683.org.readthedocs.build/