[issue26822] itemgetter/attrgetter/methodcaller objects ignore keyword arguments

2017-02-06 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Seems I missed to attach a patch. Opened issue29460 for this tweak. -- ___ Python tracker ___ ___

[issue26822] itemgetter/attrgetter/methodcaller objects ignore keyword arguments

2016-04-30 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > 2) my attempt caused a crash. I found an error in my attempt. Here is a patch that correctly define macros for _PyArg_NoKeywords and _PyArg_NoPositional micro-optimization. I don't know wherever it is worth to push it. --

[issue26822] itemgetter/attrgetter/methodcaller objects ignore keyword arguments

2016-04-29 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > Can't we use a macro to implement this micro-optimization, instead of > modifying each call to _PyArg_NoKeywords? I proposed this idea above. But then I have found that 1) most usages of _PyArg_NoKeywords are not in performance critical code and 2) my atte

[issue26822] itemgetter/attrgetter/methodcaller objects ignore keyword arguments

2016-04-29 Thread STINNER Victor
STINNER Victor added the comment: -if (!_PyArg_NoKeywords("itemgetter", kw)) +if (kw != NULL && !_PyArg_NoKeywords("itemgetter", kw)) Can't we use a macro to implement this micro-optimization, instead of modifying each call to _PyArg_NoKeywords? -- nosy: +haypo ___

[issue26822] itemgetter/attrgetter/methodcaller objects ignore keyword arguments

2016-04-28 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Upon closer inspection, redefine _PyArg_NoKeywords as a macro turned out to be not such a good idea. Other use of _PyArg_NoKeywords are in __new__ and __init__ methods. Create these objects in most cases (except may be slice) is performance critical operatio

[issue26822] itemgetter/attrgetter/methodcaller objects ignore keyword arguments

2016-04-28 Thread Roundup Robot
Roundup Robot added the comment: New changeset 54663cbd0de1 by Serhiy Storchaka in branch '3.5': Issue #26822: Decreased an overhead of using _PyArg_NoKeywords() in calls of https://hg.python.org/cpython/rev/54663cbd0de1 New changeset 22caee20223e by Serhiy Storchaka in branch 'default': Issue #

[issue26822] itemgetter/attrgetter/methodcaller objects ignore keyword arguments

2016-04-26 Thread Raymond Hettinger
Raymond Hettinger added the comment: The patch looks good and is ready to apply. The macro also is a fine idea. -- ___ Python tracker ___ ___

[issue26822] itemgetter/attrgetter/methodcaller objects ignore keyword arguments

2016-04-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Here is a patch that adds fast checks before calling _PyArg_NoKeywords(). Other option is redefine _PyArg_NoKeywords as a macro: #define _PyArg_NoKeywords(name, kw) ((kw) != NULL && _PyArg_NoKeywords((name), (kw))) This will affect all usages of _PyArg_NoK

[issue26822] itemgetter/attrgetter/methodcaller objects ignore keyword arguments

2016-04-24 Thread Raymond Hettinger
Raymond Hettinger added the comment: In general there should be an early out test for keywords==NULL before calling the comparatively high overhead function _PyArg_NoKeywords. That function adds overhead everywhere it is used and provides zero benefit to correct programs in order to provide

[issue26822] itemgetter/attrgetter/methodcaller objects ignore keyword arguments

2016-04-23 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- assignee: -> serhiy.storchaka resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___ __

[issue26822] itemgetter/attrgetter/methodcaller objects ignore keyword arguments

2016-04-23 Thread Roundup Robot
Roundup Robot added the comment: New changeset 16461a0016bf by Serhiy Storchaka in branch '3.5': Issue #26822: itemgetter, attrgetter and methodcaller objects no longer https://hg.python.org/cpython/rev/16461a0016bf New changeset 9b565815079a by Serhiy Storchaka in branch '2.7': Issue #26822: it

[issue26822] itemgetter/attrgetter/methodcaller objects ignore keyword arguments

2016-04-22 Thread Martin Panter
Martin Panter added the comment: This seems like a good change, and the patch looks correct. -- nosy: +martin.panter ___ Python tracker ___ __

[issue26822] itemgetter/attrgetter/methodcaller objects ignore keyword arguments

2016-04-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > It really seems like methodcaller should allow additional arguments > (positional and keyword though) This is good argument for raising an exception. Wrong expectations can lead to incorrect code. -- ___ Python

[issue26822] itemgetter/attrgetter/methodcaller objects ignore keyword arguments

2016-04-21 Thread Xiang Zhang
Xiang Zhang added the comment: This makes sense. It makes the C version and Python version consistent. -- nosy: +xiang.zhang ___ Python tracker ___ __

[issue26822] itemgetter/attrgetter/methodcaller objects ignore keyword arguments

2016-04-21 Thread Josh Rosenberg
Josh Rosenberg added the comment: Seems sensible for itemgetter and attrgetter, where all but the first argument is nonsensical anyway. It really seems like methodcaller should allow additional arguments (positional and keyword though), a la functools.partial (the difference being the support

[issue26822] itemgetter/attrgetter/methodcaller objects ignore keyword arguments

2016-04-21 Thread Serhiy Storchaka
New submission from Serhiy Storchaka: itemgetter(), attrgetter() and methodcaller() objects require one argument. They raise TypeError if less or more than one positional argument is provided. But they totally ignore any keyword arguments. >>> import operator >>> f = operator.itemgetter(1) >>>