Message55026
I also would like to have a built-in identity function (in fact, I found this by googling "python identity function"). My use-case is a bit different. I ofter find myself wanting to simply specify a function for be used in a loop, something like:
def f(items):
if something:
wrapper = int
else:
wrapper = identity
for item in items:
yield wrapper(item)
of course, usually it's a bit more complex than that, but you get the idea... and I supposed its actually more like the previous use-case than I thought.
I realize I could just use "lambda x: x", but I feel that comes with an unnecessary performance impact for something so trivial. I don't know how much python does to compile built-in functions, but I imagine that the identity function can be mostly optimized out at compile time if it were built-in.
Just my two-cents.
|
|
Date |
User |
Action |
Args |
2007-08-23 16:12:36 | admin | link | issue1673203 messages |
2007-08-23 16:12:36 | admin | create | |
|