Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #72096

Re: confused about the different built-in functions in Python

From Terry Reedy <tjreedy@udel.edu>
Subject Re: confused about the different built-in functions in Python
Date 2014-05-26 22:00 -0400
References (1 earlier) <6C977160E42.0000036Ccodemonkey@inbox.com> <mailman.10353.1401130279.18130.python-list@python.org> <87r43gfjqy.fsf@elektro.pacujo.net> <mailman.10356.1401133664.18130.python-list@python.org> <87ioosffh3.fsf@elektro.pacujo.net>
Newsgroups comp.lang.python
Message-ID <mailman.10358.1401156020.18130.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: confused about the different built-in functions in Python Terry Reedy <tjreedy@udel.edu> - 2014-05-26 14:51 -0400
  Re: confused about the different built-in functions in Python Marko Rauhamaa <marko@pacujo.net> - 2014-05-26 22:00 +0300
    Re: confused about the different built-in functions in Python Christian Heimes <christian@python.org> - 2014-05-26 21:47 +0200
      Re: confused about the different built-in functions in Python Marko Rauhamaa <marko@pacujo.net> - 2014-05-26 23:32 +0300
        Re: confused about the different built-in functions in Python Marko Rauhamaa <marko@pacujo.net> - 2014-05-26 23:58 +0300
          Re: confused about the different built-in functions in Python Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-05-27 11:14 +1200
          Re: confused about the different built-in functions in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-27 01:21 +0000
        Re: confused about the different built-in functions in Python Terry Reedy <tjreedy@udel.edu> - 2014-05-26 22:00 -0400

csiph-web