-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
gh-137740: Clarify __del__ invocation mechanism in reference counting #137741
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
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.
Thanks for contributing, but I've been working on upstreaming this tutorial to replace this part of the documentation. We can go through the effort of reviewing and landing this if you want, but keep in mind that it will likely be lost soon anyway.
Doc/extending/extending.rst
Outdated
which invokes the object's ``tp_dealloc`` function (``subtype_dealloc`` for Python | ||
class instances). During deallocation, ``subtype_dealloc`` calls ``tp_finalize``, | ||
which is mapped to the ``__del__`` method for Python classes (see :pep:`442`). |
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.
We need to use Sphinx references to link to the members here.
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 have added references, to the best of my knowledge. Regardless of them being obsolete, I would really appreciate it to go through review process if possible, and get some feedbacks. They would help broaden my understanding, and I want to keep on supporting this project in ways I can.
Additionally, in your new tutorial, would it be possible to at keep something like this (thin ice) part. Normally, rigid examples like this gives an alternative perspective to understand things better, especially, for folks like me, new to cpython internals world.
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'll see if there's a place to work it in, but the idea is to completely change how we explain reference counting.
Normally, rigid examples like this gives an alternative perspective to understand things better, especially, for folks like me, new to cpython internals world.
Yeah, I agree, that's why we're going to drop this section and use a tutorial that's been battle-tested.
disposing of it will call its :meth:`!__del__` method. | ||
disposing of it will call its :meth:`!__del__` method. Internally, | ||
:c:func:`PyList_SetItem` calls :c:func:`Py_DECREF` on the replaced item, | ||
which invokes replaced item's corrresponding |
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.
Typo:
which invokes replaced item's corrresponding | |
which invokes replaced item's corresponding |
Issue : gh-137740: Clarify reference counting details in "Thin Ice" section in
extending
documentation📚 Documentation preview 📚: https://cpython-previews--137741.org.readthedocs.build/