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

Łukasz Langa lukasz at langa.pl
Mon May 27 15:31:26 CEST 2013


On 26 maj 2013, at 03:37, Nick Coghlan <ncoghlan at gmail.com> wrote:

On Sun, May 26, 2013 at 9:07 AM, PJ Eby <pje at telecommunity.com> wrote:

On Sat, May 25, 2013 at 4:16 PM, Łukasz Langa <lukasz at langa.pl> wrote:

So, the latest document is live: http://www.python.org/dev/peps/pep-0443/

The code is here: http://hg.python.org/features/pep-443/file/tip/Lib/functools.py#l363 Hmm, I find the use of the variable name "dispatchcache" for a cache that dispatch() doesn't actually use to be confusing.

Why? It's a cache for dispatches, hence "dispatch_cache". It might not be obvious at first, unless you're Polish ;)

It also doesn't make sense to me that dispatch() itself bypasses the cache - I would expect all the cache manipulation to be in dispatch(), and there to be a separate "findimpl()" function that is invoked to handle cache misses.

This is exactly what I did now. I also exposed ._clear_cache() and the uncached ._find_impl() if somebody finds it necessary to use it. Both are left undocumented.

-- Best regards, Łukasz Langa

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



More information about the Python-Dev mailing list