On 5/15/2015 4:59 AM, Marko Rauhamaa wrote:
Must a method lookup necessarily involve object creation?
Where is matters, inside loops, method lookup can be avoided after doing
it once.
for i in range(1000000): ob.meth(i)
versus
meth = ob.meth
for i in range(1000000): meth(i)
For working with a single stack:
a = []
apush = stack.append
apop = stack.pop
# Now apush(x), apop(x), and test with 'if a:' as desired.
Being able to do this was part of my rational for adding list.pop, about
15 years ago.
--
Terry Jan Reedy
--
https://mail.python.org/mailman/listinfo/python-list