[Python-ideas] PEP 443 - multiple types registered

Ethan Furman ethan at stoneleaf.us
Thu Jun 6 02:10:53 CEST 2013


On 06/05/2013 05:05 PM, João Bernardo wrote:
>> fun.register() does return the decorated function. This is why the example above works. @singledispatch returns a compatible wrapper, which is analogous to what @lru_cache and countless other decorators do. Is there something I am missing
>> here?
>
> Copied from the PEP text:
>
>      The register() attribute returns the *undecorated *function. This enables decorator stacking, pickling, as well as
> creating unit tests for each variant independently:

The function is undecorated because it is simply a registration mechanism.  The function does not need to be altered for 
this to work.

--
~Ethan~


More information about the Python-ideas mailing list