[So I wrote some code for a max/min that assumes a bottleneck on generating the data](https://stackoverflow.com/questions/22203740/get-minimum-and-maximum-values-from-a-for-in-loop/22204272#22204272) (else I'd just use `max` and `min`), and it takes a key function, which if not given uses an identity function:

```
if key is None:
    key = lambda x: x

```

and then later:

```
for i in iterable:
    key_i = key(i)

```

And since the bottleneck is on the generator, the question might be moot, but if there's no key, I call `lambda x: x` for every item. *I would assume that Python could optimize this identity function away. Can someone tell me if it does?* Or if it doesn't, how expensive is it? Is there a way to do this better without doubling my line count (e.g. ternary operators)?