[New-bugs-announce] [issue16832] Expose cache validity checking support in ABCMeta

Nick Coghlan report at bugs.python.org
Tue Jan 1 04:38:24 CET 2013

New submission from Nick Coghlan:

ABCMeta uses an internal counter to invalidate the negative caches when a register() call changes the virtual inheritance graph. (A global count of register() calls is stored on ABCMeta, which ABCMeta.__instancecheck__ and ABCMeta.__subclasscheck__ then compare to a copy cached on the individual ABC)

To properly handle register() method calls on ABCs, generic function implementations also need a way to invalidate their own caches when that graph changes.

It seems like the simplest way to handle this would be to expose a read-only "ABCMeta.cache_token" property. Generic function implementations could then work the same way as ABCMeta itself: store explicit implementation registrations and a cache of derived implementations separately, and if a saved copy of the cache token doesn't match the current value of ABCMeta.cache_token, clear the derived cache.

components: Library (Lib)
messages: 178725
nosy: ncoghlan
priority: normal
severity: normal
status: open
title: Expose cache validity checking support in ABCMeta
versions: Python 3.4

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list