[issue27137] functools.partial: Inconsistency between Python and C implementations

2016-05-29 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- nosy: +brett.cannon ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://ma

[issue27137] functools.partial: Inconsistency between Python and C implementations

2016-05-29 Thread Emanuel Barry
Emanuel Barry added the comment: Functionally, both versions are equivalent, but one is a class and the other is not. From PEP 399: "Technical details of the VM providing the accelerated code are allowed to differ as necessary, e.g., a class being a `type` when implemented in C." It clearly s

[issue27137] functools.partial: Inconsistency between Python and C implementations

2016-05-29 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: PEP 399 requires that the C code must pass the test suite used for the pure Python code. -- ___ Python tracker ___ __

[issue27137] functools.partial: Inconsistency between Python and C implementations

2016-05-28 Thread STINNER Victor
STINNER Victor added the comment: The PEP 399 requires that the Python implementation behaves like the C accelerator, no? I didn't check the specific case of this issue. -- ___ Python tracker __

[issue27137] functools.partial: Inconsistency between Python and C implementations

2016-05-28 Thread Emanuel Barry
Emanuel Barry added the comment: Serhiy, it seems as though _functools is always required for functools to work - heck, tests start to fail all over the place if it isn't available, because functools.reduce doesn't exist. Subclassing _functools.partial is already tested for, so I wouldn't qual

[issue27137] functools.partial: Inconsistency between Python and C implementations

2016-05-28 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: If the Python implementation is just a rough example, and the functools module always require the _functools module, exact behavior of the Python implementation is not very important, as well as its performance. If the functools module can be used without C

[issue27137] functools.partial: Inconsistency between Python and C implementations

2016-05-28 Thread Raymond Hettinger
Raymond Hettinger added the comment: This kind of feature creep has a cost in tern complexity, maintenance, risk of bugs, loss of a clean example for others learn from, and in slower code. -- assignee: rhettinger -> ncoghlan ___ Python tracker

[issue27137] functools.partial: Inconsistency between Python and C implementations

2016-05-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: One problem with current Python implementation is that it doesn't support pickling. The ability of pickling functools.partial() is used in the pickle module for supporting __newobj_ex__ with pickle protocols 2 and 3 (issue24164) and for supporting pickling o

[issue27137] functools.partial: Inconsistency between Python and C implementations

2016-05-27 Thread Raymond Hettinger
Raymond Hettinger added the comment: -1 I prefer to keep the current clean, easy-to-understand, easy-to-get-right code which complies with the documented API. I see no real benefit in twisting the code around to match non-guaranteed implementation details. --

[issue27137] functools.partial: Inconsistency between Python and C implementations

2016-05-27 Thread Emanuel Barry
Emanuel Barry added the comment: Attached patch turns the Python implementation of functools.partial into a class. The implementation is as close to the C version as possible, except __repr__ where I went for a different, more Pythonic approach (output is identical). I haven't yet added tests

[issue27137] functools.partial: Inconsistency between Python and C implementations

2016-05-27 Thread Xiang Zhang
Changes by Xiang Zhang : -- nosy: +xiang.zhang ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyt

[issue27137] functools.partial: Inconsistency between Python and C implementations

2016-05-27 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- assignee: -> rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https

[issue27137] functools.partial: Inconsistency between Python and C implementations

2016-05-27 Thread STINNER Victor
Changes by STINNER Victor : -- nosy: +haypo ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python

[issue27137] functools.partial: Inconsistency between Python and C implementations

2016-05-27 Thread Emanuel Barry
New submission from Emanuel Barry: 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