GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing mail.python.org — [Python-Dev] Supporting functools.singledispatch with classes. [Python-Dev] Supporting functools.singledispatch with classes.Nick Coghlan ncoghlan at gmail.comFri Dec 29 10:02:19 EST 2017
On 28 December 2017 at 04:22, Ethan Smith <ethan at ethanhs.me> wrote: > Okay, if there is no further feedback, I will work on a singledispatchmethod > decorator like partialmethod. > > For the future perhaps, would it not be possible to tell that the passed > argument is a descriptor/function and dispatch to the correct > implementation, thus not needing two functions for essentially the same > thing? > > It seems more straightforward to make the implementation a bit more complex > to provide a single, simple API to users. "Add 'method' to the decorator name when decorating a method" is a pretty simple rule to remember - it's much easier than "Add 'arg_index=1'" (which is a comparatively arbitrary adjustment that requires a fairly in depth understanding of both the descriptor protocol and type-based function dispatch to follow). And you need the change to be explicitly opt-in *somehow*, in order to avoid breaking any existing code that relies on methods decorated with "singledispatch" dispatching on the bound class. Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-Dev mailing list |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |