A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2017-September/149441.html below:

[Python-Dev] PEP 559 - built-in noop()

[Python-Dev] PEP 559 - built-in noop()Michel Desmoulin desmoulinmichel at gmail.com
Sun Sep 10 09:51:48 EDT 2017
Don't we already have the mock module for that ? A mowk works as a noop,
will be ok with being used as a context manager and allow chaining...

Either way, what would a noop function really give you compared to
lambda *a, **b: None ?

A be bit shorter to write. Maybe faster to run. But do you use it so
much that it needs to be included ? It's not rocket science.

And as a built-in, noon of the less.

If it's coded it in C to gain perfs, then:

- let's put it in functools, not in built-in. I often wish for partial
to be built-in, but it's not. Honestly the fonctools and itertools
module should be autoimported (I always do in my PYTHONSTARTUP). But no
pony for us, let's not clutter the global name spaces.
- provide it with it's little sister, the identity function. They almost
always go hand in hand and doing the whole work of this PEP is a nice
opportunity. sorted/max/min/sort and most validation callbacks have an
identity function as default parameters. We would have then
functools.noop and functools.identity.
- provide a pure Python backport.

Aternatively, just rewrite part of the mock module in C. You'll get a
fast noop, with a lot of features, and as a bonus would speed up a lot
of unit tests around here.
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4