Why does deleting classes not lower the sys.refcount of them or remove them from weakref.WeakSets?
It's also like this for normal class definitions, I'm just illustrating the seemingly ridiculous nature of this by using the type function.
>>> _reg = weakref.WeakSet()
>>> MyClass = type('MyClass', (), {})
>>> sys.getrefcount(MyClass)
5
>>> _reg.add(MyClass)
>>> len(_reg)
1
>>> del MyClass
>>> len(_reg)
1
>>> sys.getrefcount([*_reg][0])
4
Posted Aug 14, 2017, 7:44 PM UTC
83