This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author kristjan.jonsson
Recipients kristjan.jonsson, pitrou, vstinner
Date 2013-05-13.11:40:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1368445209.67.0.271613335351.issue17936@psf.upfronthosting.co.za>
In-reply-to
Content
Yes I am sure.  Please see the previous reasoning.  Igoring assigning to __bases__ for the moment...

Every class deletion will try to remove itself from the list.  Either it will 
a) find an existing reference in the weakref and remove it
b) find a None in the weakref and remove it.

b) is guaranteed to be the old weakref, because every previous class removal has also succeeded.  At any time, there is at most a single stale weakref in the list.

And _even_if_ there is a flaw in the argument, every call will remove _one_ stale (or just about to become stale) weakref from the list.  Whether it is its own weakref or that of a previous deletion is immaterial.  The removal of _one_ entry for each class deletion keeps the list at its optimal size.

For the case of assigning to __bases__, of course, the weakrefs are not stale and we must find the correct class to remove for correctness.

I don't want guaranteed O(1) behaviour, just O(1) for the common case of creating a class, or a few classes, and then removing them.
History
Date User Action Args
2013-05-13 11:40:09kristjan.jonssonsetrecipients: + kristjan.jonsson, pitrou, vstinner
2013-05-13 11:40:09kristjan.jonssonsetmessageid: <1368445209.67.0.271613335351.issue17936@psf.upfronthosting.co.za>
2013-05-13 11:40:09kristjan.jonssonlinkissue17936 messages
2013-05-13 11:40:09kristjan.jonssoncreate