
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2017-12-19 22:23 byethan smith, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 4987 | closed | ethan smith,2017-12-23 07:12 | |
| PR 6306 | merged | ethan smith,2018-03-29 10:38 | |
| PR 12580 | merged | methane,2019-03-27 08:36 | |
| Messages (7) | |||
|---|---|---|---|
| msg308687 -(view) | Author: Ethan Smith (ethan smith)* | Date: 2017-12-19 22:23 | |
Consider the following:from functools import singledispatchclass Dispatch: @singledispatch def foo(self, a): return a @foo.register(int) def _(self, a): return "int" @foo.register(str) def _(self, a): return "str"cls = Dispatch()cls.foo(3) # 3cls.foo('hm') # 'hm'I find this quite unintuitive. Essentially, since singledispatch dispatches based solely on a functions first argument, it is useless on methods unless one wraps it and modifies how it uses the internal wrapper function. I believe this should be relatively easy to fix with adding a check of inspect.ismethod and then modifying the number of the checked argument where appropriate.I'm happy to write a patch if this change is seen as a good idea. | |||
| msg308944 -(view) | Author: Ivan Levkivskyi (levkivskyi)*![]() | Date: 2017-12-22 23:53 | |
I have also noticed this problem and I like the idea. It appeared some time ago on python-ideas, but no one has written a patch. | |||
| msg314644 -(view) | Author: Alyssa Coghlan (ncoghlan)*![]() | Date: 2018-03-29 12:17 | |
Added Łukasz to the nosy list, as I'd like his +1 before accepting this change (I do still think it's a good idea, for the same reasons we added partialmethod). | |||
| msg314817 -(view) | Author: Łukasz Langa (lukasz.langa)*![]() | Date: 2018-04-02 17:40 | |
+1 | |||
| msg317765 -(view) | Author: Łukasz Langa (lukasz.langa)*![]() | Date: 2018-05-26 20:38 | |
New changesetc651275afe8515b2cf70b8152e19ce39df88f0dd by Łukasz Langa (Ethan Smith) in branch 'master':bpo-32380: Create functools.singledispatchmethod (#6306)https://github.com/python/cpython/commit/c651275afe8515b2cf70b8152e19ce39df88f0dd | |||
| msg317941 -(view) | Author: Ethan Smith (ethan smith)* | Date: 2018-05-28 22:47 | |
This was fixed, so I think it can be closed. | |||
| msg338945 -(view) | Author: Inada Naoki (methane)*![]() | Date: 2019-03-27 09:15 | |
New changesetbc284f0c7a9a7a9a4bf12c680823023a6770ce06 by Inada Naoki in branch 'master':bpo-32380: add "versionadded: 3.8" to singledispatchmethod (GH-12580)https://github.com/python/cpython/commit/bc284f0c7a9a7a9a4bf12c680823023a6770ce06 | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:55 | admin | set | github: 76561 |
| 2019-03-27 09:15:21 | methane | set | nosy: +methane messages: +msg338945 |
| 2019-03-27 08:36:17 | methane | set | pull_requests: +pull_request12524 |
| 2018-05-28 22:47:25 | ethan smith | set | status: open -> closed resolution: fixed messages: +msg317941 stage: patch review -> resolved |
| 2018-05-26 20:38:36 | lukasz.langa | set | messages: +msg317765 |
| 2018-04-02 17:40:29 | lukasz.langa | set | messages: +msg314817 |
| 2018-03-29 12:17:13 | ncoghlan | set | nosy: +ncoghlan,lukasz.langa messages: +msg314644 |
| 2018-03-29 10:44:13 | ethan smith | set | versions: + Python 3.8, - Python 3.6 |
| 2018-03-29 10:38:40 | ethan smith | set | pull_requests: +pull_request6024 |
| 2017-12-23 07:12:16 | ethan smith | set | keywords: +patch stage: patch review pull_requests: +pull_request4873 |
| 2017-12-22 23:53:47 | levkivskyi | set | nosy: +levkivskyi messages: +msg308944 |
| 2017-12-19 22:23:08 | ethan smith | create | |