[Python-Dev] PEP 443 - Single-dispatch generic functions

Łukasz Langa lukasz at langa.pl
Thu May 23 22:10:03 CEST 2013

On 23 maj 2013, at 20:59, PJ Eby <pje at telecommunity.com> wrote:

> As to the ability to do multiple types registration, you could support
> it only in type annotations, e.g.:
>    @func.register
>    def doit(foo: [int, float]):
>        ...

Initially I thought so, too. But it seems other people might think this
means "a sequence with the first element being an integer, and the second
a float". The BDFL seems to have yet a different idea:


This is clearly material for a separate PEP, wink wink, nudge nudge.

To the point though. Based on this, and the fact PEP 8 currently disallows
annotations within the standard library, I came to the conclusion that
currently we should not include the annotation-driven form.

> I generally lean towards returning the undecorated function, so that if you say:
>    @func.register
>    def do_int(foo: int):
>        ...

Me too. The PEP has been updated to specify that explicitly.

Best regards,
Łukasz Langa

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

More information about the Python-Dev mailing list