<div dir="ltr">I can't tell whether this was meant seriously, but I don't think it's worth it. People can easily write their own dummy function and give it any damn semantics they want. Let's reject the PEP.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 9, 2017 at 11:46 AM, Barry Warsaw <span dir="ltr"><<a href="mailto:barry@python.org" target="_blank">barry@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I couldn’t resist one more PEP from the Core sprint.  I won’t reveal where or how this one came to me.<br>
<br>
-Barry<br>
<br>
PEP: 559<br>
Title: Built-in noop()<br>
Author: Barry Warsaw <<a href="mailto:barry@python.org">barry@python.org</a>><br>
Status: Draft<br>
Type: Standards Track<br>
Content-Type: text/x-rst<br>
Created: 2017-09-08<br>
Python-Version: 3.7<br>
Post-History: 2017-09-09<br>
<br>
<br>
Abstract<br>
========<br>
<br>
This PEP proposes adding a new built-in function called ``noop()`` which does<br>
nothing but return ``None``.<br>
<br>
<br>
Rationale<br>
=========<br>
<br>
It is trivial to implement a no-op function in Python.  It's so easy in fact<br>
that many people do it many times over and over again.  It would be useful in<br>
many cases to have a common built-in function that does nothing.<br>
<br>
One use case would be for PEP 553, where you could set the breakpoint<br>
environment variable to the following in order to effectively disable it::<br>
<br>
    $ setenv PYTHONBREAKPOINT=noop<br>
<br>
<br>
Implementation<br>
==============<br>
<br>
The Python equivalent of the ``noop()`` function is exactly::<br>
<br>
    def noop(*args, **kws):<br>
        return None<br>
<br>
The C built-in implementation is available as a pull request.<br>
<br>
<br>
Rejected alternatives<br>
=====================<br>
<br>
``noop()`` returns something<br>
----------------------------<br>
<br>
YAGNI.<br>
<br>
This is rejected because it complicates the semantics.  For example, if you<br>
always return both ``*args`` and ``**kws``, what do you return when none of<br>
those are given?  Returning a tuple of ``((), {})`` is kind of ugly, but<br>
provides consistency.  But you might also want to just return ``None`` since<br>
that's also conceptually what the function was passed.<br>
<br>
Or, what if you pass in exactly one positional argument, e.g. ``noop(7)``.  Do<br>
you return ``7`` or ``((7,), {})``?  And so on.<br>
<br>
The author claims that you won't ever need the return value of ``noop()`` so<br>
it will always return ``None``.<br>
<br>
Coghlin's Dialogs (edited for formatting):<br>
<br>
    My counterargument to this would be ``map(noop, iterable)``,<br>
    ``sorted(iterable, key=noop)``, etc. (``filter``, ``max``, and<br>
    ``min`` all accept callables that accept a single argument, as do<br>
    many of the itertools operations).<br>
<br>
    Making ``noop()`` a useful default function in those cases just<br>
    needs the definition to be::<br>
<br>
       def noop(*args, **kwds):<br>
           return args[0] if args else None<br>
<br>
    The counterargument to the counterargument is that using ``None``<br>
    as the default in all these cases is going to be faster, since it<br>
    lets the algorithm skip the callback entirely, rather than calling<br>
    it and having it do nothing useful.<br>
<br>
<br>
Copyright<br>
=========<br>
<br>
This document has been placed in the public domain.<br>
<br>
<br>
..<br>
   Local Variables:<br>
   mode: indented-text<br>
   indent-tabs-mode: nil<br>
   sentence-end-double-space: t<br>
   fill-column: 70<br>
   coding: utf-8<br>
   End:<br>
<br>
<br>______________________________<wbr>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/guido%40python.org" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/options/python-dev/<wbr>guido%40python.org</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div>