This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jackdied
Recipients
Date 2007-03-22.20:15:26
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Raymond, please make a pronouncement.

+1 on adding it to the operator module.  Lots of one liners go there.
-1000 to having it take more than one argument.  If I saw this
  identity(ob, 42)
for the first time (or second, or ...) I would have to look up what
it does.  As a plain identity function it is obvious.

Patch to operator.c, liboperator.tex, test_operator.py, NEWS attached.
Raymond, there isn't a good section in the doc for this function so I added it to the logical operators.  The fact that there isn't a good section for it might be a mark against it being included.

It is a couple times faster than the python version which isn't exciting.

sprat:~/src/python-rw> ./python Lib/timeit.py -s "from operator import identity" "identity(None)"
10000000 loops, best of 3: 0.161 usec per loop
sprat:~/src/python-rw> ./python Lib/timeit.py -s "def identity(ob): return ob" "identity(None)"
1000000 loops, best of 3: 0.421 usec per loop

File Added: identity.patch
History
Date User Action Args
2007-08-23 16:12:36adminlinkissue1673203 messages
2007-08-23 16:12:36admincreate