confused about the different built-in functions in Python
Terry Reedy
tjreedy at udel.edu
Mon May 26 22:00:03 EDT 2014
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:
spush(item)
while stack and condition:
p = process(spop)
...
--
Terry Jan Reedy
More information about the Python-list
mailing list