[Tutor] Performance list vs. deque for [-1]

Alan Gauld alan.gauld at btinternet.com
Thu Aug 12 09:44:54 CEST 2010


"Knacktus" <knacktus at googlemail.com> wrote

> I'm wondering what's the fastet datatype in python to lookup the 
> last element in an ordered collection.

When in doubt timeit()

But I would expect a standard list to be prettyy fast isf you are
only concerned about accessing the last element [-1]

> Also, the collections will be small (about 10-20 elements), but I 
> will have huge amount (50000-100000) of those collections which need 
> to be processed for certain tasks in my application.

Sounds like you should be more concerned about how you locate
the specific collection than about finding the last element in each...
What kind of container will the collections sit in?


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list