Add Nick's feedback.
This commit is contained in:
parent
80b1eb58ae
commit
f5e0e7c2be
18
pep-0559.rst
18
pep-0559.rst
|
@ -60,6 +60,24 @@ you return ``7`` or ``((7,), {})``? And so on.
|
|||
The author claims that you won't ever need the return value of ``noop()`` so
|
||||
it will always return ``None``.
|
||||
|
||||
Coghlin's Dialogs (edited for formatting):
|
||||
|
||||
My counterargument to this would be ``map(noop, iterable)``,
|
||||
``sorted(iterable, key=noop)``, etc. (``filter``, ``max``, and
|
||||
``min`` all accept callables that accept a single argument, as do
|
||||
many of the itertools operations).
|
||||
|
||||
Making ``noop()`` a useful default function in those cases just
|
||||
needs the definition to be::
|
||||
|
||||
def noop(*args, **kwds):
|
||||
return args[0] if args else None
|
||||
|
||||
The counterargument to the counterargument is that using ``None``
|
||||
as the default in all these cases is going to be faster, since it
|
||||
lets the algorithm skip the callback entirely, rather than calling
|
||||
it and having it do nothing useful.
|
||||
|
||||
|
||||
Copyright
|
||||
=========
|
||||
|
|
Loading…
Reference in New Issue