Why is using a key function so much slower? Languages

Why is using a key function so much slower?

There is a drastic performance hit when using a keyfunc in heapq.nlargest:I expected a small extra cost, perhaps something like 30% - not 400%. This degradation seems to be reproducible over a few different data sizes. You can see in the source code there is a special-case handling for if...
Read More