[Python-Dev] PEP 443 - Single-dispatch generic functions (including ABC support)

Łukasz Langa lukasz at langa.pl
Sat May 25 16:53:59 CEST 2013

On 25 maj 2013, at 16:08, PJ Eby <pje at telecommunity.com> wrote:

> ISTM there should be some way to get at the raw
> registration info, perhaps by exposing a dictproxy for the registry.

Is that really useful? Just today Antoine asked about changing
behaviour of __subclasses__(), suspecting it isn't used in real world
code anyway. What you're proposing is the functional equivalent of

If you need direct access to the registry, do you think the ability to
specify your own registry container isn't enough?

> The way to detect ABC registrations is via the
> ABCMeta._abc_invalidation_counter attribute: if its value is different
> than the previous value saved with the cache, the cache must be
> cleared, and the new value stored.

Wow, I was looking at it just today morning and somehow missed how it
can be used. Great idea, I'll play around with it later today.

> (Unfortunately, this is a private attribute at the moment; it might be
> a good idea to make it public, however, because it's needed for any
> sort of type dispatching mechanism, not just this one particular
> generic function implementation.)

I think we can safely use it within the standard library, anyway. As for
making it public, it's an idea for a separate discussion.

> This would basically eliminate doing any extra (Python) function calls
> in the common case, and might actually be faster than my current
> simplegeneric implementation on PyPI (which doesn't even do ABCs at
> the moment).

Yes, that sounds neat.

Thanks for feedback!

Best regards,
Łukasz Langa

WWW: http://lukasz.langa.pl/
Twitter: @llanga
IRC: ambv on #python-dev

More information about the Python-Dev mailing list