Message266503
functools.partial is a class in C, but the Python implementation is a function. This doesn't matter for most use cases where you only want the end result of the call to partial.
A simple line in the REPL tells me enough (or so I thought) that I wouldn't need to check the implementation:
>>> functools.partial
<class 'functools.partial'>
Oh, it's a class, which means I can subclass it to add a custom repr for my needs.
Unsurprisingly, it works. It may not be the best idea to subclass something that is meant to be final, but I'm simply overriding a single method, what could possibly go wrong? Besides one of the implementations not actually being a class.
I'm suggesting to make the Python implementation also a class, for consistency and making sure that both the C and Python implementation match, in case someone else wants to do that too.
The documentation ( https://docs.python.org/3/library/functools.html#functools.partial ) doesn't state that the Python and C implementations differ, but IMO this isn't a documentation bug.
I haven't written a patch yet, will probably be done by tomorrow.
Note: I haven't actually encountered this issue, but I suspect that it might arise if someone doesn't have access to _functools for whatever reason. And IMO, Python and C implementations of a feature should be fully equivalent (modulo implementation details à la OrderedDict.__root).
Thoughts? |
|
Date |
User |
Action |
Args |
2016-05-27 16:39:18 | abarry | set | recipients:
+ abarry, rhettinger, ncoghlan |
2016-05-27 16:39:18 | abarry | set | messageid: <1464367158.87.0.208604382314.issue27137@psf.upfronthosting.co.za> |
2016-05-27 16:39:18 | abarry | link | issue27137 messages |
2016-05-27 16:39:18 | abarry | create | |
|