Pop a list from beginning ? and memory saving...

holger krekel pyth at devel.trillke.net
Tue Jun 18 14:26:11 EDT 2002


[Tim Peters]
> [James T. Dennis]
> > ...
> >  So, the critical question is:
> >
> > 	Is the list's reverse() method done in place
> 
> Yes.
> 
> > and does it run in linear time
> 
> Yes.
> 
> > (or better?
> 
> No.  It does len(list)/2 swaps.

in another thread we had some discussion about a
reverse-iterator.  You could write

    for item in iters.reverse(list):
        # item iterates over list's items backwards
        # but the list itself stays unmodified. 

Do you agree that this would be a good idea?

please-share-your-brain-ly y'rs, holger





More information about the Python-list mailing list