[issue17936] O(n**2) behaviour when adding/removing classes

Kristján Valur Jónsson report at bugs.python.org
Mon May 13 19:29:59 CEST 2013


Kristján Valur Jónsson added the comment:

That is not sufficient.  The weakrefs may have been cleared already if the deletion comes as a result of garbage collection (which is currently the only way classes get deleted.)

It is still easily demonstratably correct:
The previous version _only_ removed subclasses on setting __bases__.  Housekeeping of stale weakrefs was done when new classes were created.

This proposed version still properly removes subclasses when setting __bases__, but housekeeping of dead weakrefs is now moved to the point when a class is deleted.  To do housekeeping of stale weakrefs, it is sufficient to remove _one_ stale weakref for each class that is deleted.  It is not important that this is the correct stale weakref, all stale weakrefs are the same.

I've uploaded an updated patch with added in-line comments explaining the case.

----------
Added file: http://bugs.python.org/file30253/subtype.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17936>
_______________________________________


More information about the Python-bugs-list mailing list