[issue1568] PATCH: Armin's attribute lookup caching for 3.0

Amaury Forgeot d'Arc report at bugs.python.org
Thu Jan 17 00:50:20 CET 2008


Amaury Forgeot d'Arc added the comment:

I tried patch python30-attrcache-1.diff (after reverting the changes
made to the 2.6 branch).

But test_descr fails. The cache update does not handle the case when an
attribute is unmasked, as shown in the following code:

class A: pass
class B(A): pass
b=B()
A.x = 1
assert b.x == A.x
B.x = 2
assert b.x == B.x
del B.x
b.x         # <== AttributeError: 'B' object has no attribute 'x'

(b.x should be A.x, of course)
In debug build, a C assert() stops the program
    assert(ep->value == _PyType_LookupInternal(type, name));
which suggest that the cache is out of sync.

Then I enabled 
    #define ATTRCACHE_SETATTR_INVALIDATES
to try the other possibility suggested by Neil. This version seems to
work correctly. 
I'm currently running the test suite...

Question: why is this patch different from the 2.6 version? Does it take
advantage of some 3.0 feature?

----------
nosy: +amaury.forgeotdarc

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1568>
__________________________________


More information about the Python-bugs-list mailing list