On 5/26/2014 4:32 PM, Marko Rauhamaa wrote:

I stand corrected. I had thought the trampoline ("bound method object")
was created once and for all.

Assuming that bound methods are immutable, this is an implementation detail, either way. However, it is common for a specific method to be called just once on a specific instance. If you have a mixed-case string Ss and want the lowercase version, ss = Ss.lower(), you keep ss around as long as needed. If the bound method is needed repeatedly, you can keep *that* around too.

stack = []
spush = stack.append
spop = stack.pop

for item in it:
while stack and condition:
  p = process(spop)

Terry Jan Reedy


Reply via email to