Message55027
twobitsprite: your use-case is different from that of others. While you could use an identity function for your purposes, a lambda would work just fine. Regardless, there is call overhead, which can only be reduced by not performing a call at all.
In terms of an identity function versus tuple creation and indexing as per belopolsky's suggestion...
>>> timeit.Timer("x(1+2,3+4)", "x = lambda *args:args[-1]").timeit()
0.99381552025397468
>>> timeit.Timer("(1+2,3+4)[-1]", "").timeit()
0.49153579156927663
Tuple is faster. Just use a tuple. |
|
Date |
User |
Action |
Args |
2007-08-23 16:12:36 | admin | link | issue1673203 messages |
2007-08-23 16:12:36 | admin | create | |
|