Skip to content

bpo-46417: remove_subclass() clears tp_subclasses - #30793

Merged
vstinner merged 1 commit into
python:mainfrom
vstinner:remove_subclass_empty
Jan 22, 2022
Merged

vstinner merged 1 commit into
python:mainfrom
vstinner:remove_subclass_empty

Conversation

@vstinner

@vstinner vstinner commented Jan 22, 2022 •

Copy link
Copy Markdown
Member

The remove_subclass() function now deletes the dictionary when
removing the last subclass (if the dictionary becomes empty) to save
memory: set PyTypeObject.tp_subclasses to NULL. remove_subclass() is
called when a type is deallocated.

_PyType_GetSubclasses() no longer holds a reference to tp_subclasses:
its loop cannot modify tp_subclasses.

https://bugs.python.org/issue46417

The remove_subclass() function now deletes the dictionary when
removing the last subclass (if the dictionary becomes empty) to save
memory: set PyTypeObject.tp_subclasses to NULL. remove_subclass() is
called when a type is deallocated.

_PyType_GetSubclasses() no longer holds a reference to tp_subclasses:
its loop cannot modify tp_subclasses.
@vstinner
vstinner merged commit 2d03b73 into python:main Jan 22, 2022
@vstinner
vstinner deleted the remove_subclass_empty branch January 22, 2022 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant