On 2021-05-27 13:15, Chris Angelico wrote:
Hmmmmmmmm.... let's see.
def merge_shortest(things):
... len=len
... ...
...
merge_shortest([])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in merge_shortest
UnboundLocalError: local variable 'len' referenced before assignment
Okay, yeah, mea culpa. As several people pointed out that doesn't
work. But `len_ = len` does work. However, that doesn't change the
calculus at all for me. My point wasn't about using the exact same
variable name. It's that ANY ability to create a local variable that is
a fast-lookup shortcut for a global one is enough. My point is that
manually creating fast-lookup local-variable shortcuts is inherently a
performance hack and there's no real use in making it slightly
nicer-looking.
--
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is no
path, and leave a trail."
--author unknown
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/DPVT5ORXCDRHJXTLUVSYAFXJ3Y7A6VVM/
Code of Conduct: http://python.org/psf/codeofconduct/