[issue44019] operator.call/operator.__call__

Antony Lee report at bugs.python.org
Wed Sep 1 04:03:16 EDT 2021


Antony Lee <anntzer.lee at gmail.com> added the comment:

Python2's apply has different semantics: it takes non-unpacked arguments, i.e.

    def apply(f, args, kwargs={}): return f(*args, **kwargs)

rather than

    def call(f, *args, **kwargs): return f(*args, **kwargs)

I agree that both functions can be written in two (or one) line, but the same can be said of most functions in the operator module (def add(x, y): return x + y); from the module's doc ("efficient functions corresponding to the intrinsic operators"), I would argue that the criteria for inclusion are efficiency (operator.call is indeed fast, see the linked PR) and intrinsicness (I don't know if there's a hard definition, but function calling certainly seems intrinsic).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44019>
_______________________________________


More information about the Python-bugs-list mailing list