[Python-Dev] PEP 443 - Single-dispatch generic functions (including ABC support)
Łukasz Langa
lukasz at langa.pl
Fri May 31 03:05:46 CEST 2013
More information about the Python-Dev mailing list
Fri May 31 03:05:46 CEST 2013
- Previous message: [Python-Dev] PEP 443 - Single-dispatch generic functions (including ABC support)
- Next message: [Python-Dev] PEP 443 - Single-dispatch generic functions (including ABC support)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 31 maj 2013, at 01:51, Łukasz Langa <lukasz at langa.pl> wrote: > On 31 maj 2013, at 01:47, Łukasz Langa <lukasz at langa.pl> wrote: > >> class State: >> def __init__(self): >> self.add.register(int, self.add_int) > > Ouch, I realized this is wrong just after I hit "Send". > self.add is a staticmethod so this registration will overload > on every instance. Which is obviously bad. So, after some embarrassing head banging, here's the correct solution: https://gist.github.com/ambv/5682351 So, it *is* possible to make instance-level and class-level registration work with the existing @singledispatch code and a bit of plumbing. Obviously, all that is not necessary for actual static methods. Back to the point, though. I don't feel we should complicate the code, tests and documentation by introducing special handling for methods. In terms of pure type-driven single dispatch, we have a solution that was intentionally simple from the get-go. The next step will be predicate dispatch anyway ;)) What do you think? -- Best regards, Łukasz Langa WWW: http://lukasz.langa.pl/ Twitter: @llanga IRC: ambv on #python-dev
- Previous message: [Python-Dev] PEP 443 - Single-dispatch generic functions (including ABC support)
- Next message: [Python-Dev] PEP 443 - Single-dispatch generic functions (including ABC support)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list