Author vstinner
Recipients ebarry, mdk, serhiy.storchaka, sjpalt, vstinner
Date 2016-12-05.23:30:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> * Somehow, notify Foo that Meta has a reference to its cache, so Foo is able to invalidate Meta cache

This was implemented when the type cache was implemented in Python 2.6, but only for explicit subclasses. PyType_Modified() iterates on tp_subclasses.

PyType_Ready() updates tp_subclasses: it stores a weak reference to sub classes in each base class.

I understand that, if we want to implement this feature, type_mro_modified() should be modified to add a backward reference in each base class of the MRO. type_mro_modified() is called when a type is defined, but also when type.__bases__ is explicitly modified.

It would require to add a new slot to types, and so increase a little bit the memory usage, and slow down the creation of a type, and type.__bases__ (slow down: probably negligible, O(1) since the existing tp_subclasses uses a dict).
Date User Action Args
2016-12-05 23:30:05vstinnersetrecipients: + vstinner, serhiy.storchaka, ebarry, mdk, sjpalt
2016-12-05 23:30:05vstinnersetmessageid: <>
2016-12-05 23:30:05vstinnerlinkissue28866 messages
2016-12-05 23:30:05vstinnercreate