list.pop(0) vs. collections.dequeue

Steve Howell showell30 at yahoo.com
Tue Jan 26 00:40:29 CET 2010


--- On Mon, 1/25/10, Chris Colbert <sccolbert at gmail.com> wrote:

> 
> looking at that code, i think you could solve
> your whole problem with a single called to reversed() (which
> is NOT the same as list.reverse()) 
> 

I do not think that's actually true.  It does no good to pop elements off a copy of the list if there is still code that refers to the original list.  So I think you really do want list.reverse().

The problem with reversing the lists is that it gets sliced and diced and passed around to other methods, one of which, html_block_tag, recursively calls back to the main method.  So you could say that everybody just has to work with a reversed list, but in my mind, that would be just backward and overly complicated.

I am not completely ruling out the approach, though.  The idea of modelling the program essentially as a stack has some validity, and it probably would run faster.

https://bitbucket.org/showell/shpaml_website/src/tip/shpaml.py






More information about the Python-list mailing list