[issue28866] Type cache is not correctly invalidated on a class defining mro()

STINNER Victor report at bugs.python.org
Mon Dec 5 18:13:53 EST 2016


STINNER Victor added the comment:

The issue is that the Meta class has a reference to the class Foo in its mro() method, but Foo is not aware of Meta. So when Foo is modified, the Foo cache is invalidated, but not Meta cache.

issue28866.diff always invalidates the cache, so it works. But it is suboptimal, IMO it defeats the whole purpose of a cache.

I never defined a mro() method. I'm not sure that it's possible to have a type cache and a mro() method?

Options:

* Disable completely the cache on classes defining mro()
* Modify "Meta" (the C code implementing the type, not the Python code) to track the version tag of each class referenced by mro(). Problem: mro() is dynamic!?
* Somehow, notify Foo that Meta has a reference to its cache, so Foo is able to invalidate Meta cache

----------
title: Unexpected behavior resulting from mro() and __setattr__ in interactive mode -> Type cache is not correctly invalidated on a class defining mro()

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


More information about the Python-bugs-list mailing list