On Thu, May 27, 2021 at 04:37:10PM +0200, Ronald Oussoren wrote:
One common use for function defaults is to optimize function lookups to
local variables instead of global or builtins:
def func(arg, len=len):
# now len is a fast local lookup instead of a slow name lookup
That’s a CPython performance hack,
No it isn't. I think we can assume than any non-crappy implementation
will have faster access to locals than globals and builtins, or at least
no worse. So it is a fair expectation that any time you can turn a
global lookup into a local lookup, you should have some performance
benefit.