Re: [Python-Dev] single dispatch for instance methods

2016-10-16 Thread Aric Coady
On Oct 14, 2016, at 8:49 AM, python-dev-requ...@python.org wrote:
> Date: Fri, 14 Oct 2016 14:11:18 +1300
> From: Tim Mitchell 
> It would be nice if the @singledispatch decorator worked on instance
> methods.
> I have a reference implementation on pypi that does this (
> https://pypi.python.org/pypi/methoddispatch).

You might be interested in this thread from my multimethod library: 
https://bitbucket.org/coady/multimethod/issues/2/ 
.  It was a feature request 
for multiple dispatch to work on instance methods.  I implemented a variation 
where the initial self argument still contributed to the dispatch.

I think the same reasoning would apply in the single dispatch case:  that it’s 
not obvious the “dispatch” would occur once on the self argument to find the 
method, and then again on the “first” argument.  Especially since Py3 did away 
with bound methods, so you can call a method through its class and explicitly 
supply self as the first argument.

___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] single dispatch for instance methods

2016-10-16 Thread Tim Mitchell
An interesting idea, however from my point of view in methoddispatch there
is no dispatching on the self argument at all.
Overriding methods simply allows your subclass to have a different dispatch
table for a method than the super class.  This happens when the class is
created, not when the function is called.
When the method is called it is single-dispatched on the (single) argument
after self using the dispatch table for the class of the method.



On 17 October 2016 at 11:53, Aric Coady  wrote:

> On Oct 14, 2016, at 8:49 AM, python-dev-requ...@python.org wrote:
>
> Date: Fri, 14 Oct 2016 14:11:18 +1300
> From: Tim Mitchell 
>
> It would be nice if the @singledispatch decorator worked on instance
> methods.
> I have a reference implementation on pypi that does this (
> https://pypi.python.org/pypi/methoddispatch).
>
>
> You might be interested in this thread from my multimethod library:
> https://bitbucket.org/coady/multimethod/issues/2/.  It was a feature
> request for multiple dispatch to work on instance methods.  I implemented a
> variation where the initial self argument still contributed to the dispatch.
>
> I think the same reasoning would apply in the single dispatch case:  that
> it’s not obvious the “dispatch” would occur once on the self argument to
> find the method, and then again on the “first” argument.  Especially since
> Py3 did away with bound methods, so you can call a method through its class
> and explicitly supply self as the first argument.
>
>
>
--
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-ideas] Show more info when `python -vV`

2016-10-16 Thread INADA Naoki
(Added python-dev in CC list, because there are enough +1 already).

On Mon, Oct 17, 2016 at 3:06 PM, Chris Angelico  wrote:
> On Mon, Oct 17, 2016 at 5:02 PM, INADA Naoki  wrote:
>> $ ./python.exe -V
>> Python 3.6.0b2+
>>
>> $ ./python.exe -VV
>> Python 3.6.0b2+ (3.6:0b29adb5c804+, Oct 17 2016, 15:00:12)
>> [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)]
>
> LGTM.
>
> What's the view on backporting this to 2.7.x? We're still a good few
> years away from its death, and it'd be helpful if recent 2.7s could
> give this info too.
>
> ChrisA


I want to add it at least Python 3.6. Because one reason I want to
propose this is
I can't see exact Python version (commit id) for "nightly" or
"3.6-dev" on Travis-CI test.

But Python 3.6 is beta stage already. If we apply rule strictly, it
should be added
only in default branch (Python 3.7).

So, what version can I add this?

a. Only Python 3.7+
b. (beta) Python 3.6+
c. (maintenance) Python 2.7 and Python 3.5+

-- 
INADA Naoki  
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com