bpo-46417: remove_subclass() clears tp_subclasses (GH-30793) · python/cpython@2d03b73 · GitHub
Skip to content

Commit 2d03b73

Browse files
authored
bpo-46417: remove_subclass() clears tp_subclasses (GH-30793)
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.
1 parent f1c6ae3 commit 2d03b73

2 files changed

Lines changed: 32 additions & 9 deletions

File tree

Lib/test/test_descr.py

Lines changed: 17 additions & 0 deletions

Objects/typeobject.c

Lines changed: 15 additions & 9 deletions

0 commit comments

Comments
 (0)