Algorithmic complexity of len (list)?

Roy Smith roy at panix.com
Fri Jul 2 19:18:20 EDT 2004


Is the length of a list stored in the object, or does len() have to 
count the elements each time you call it?  In other words, is len (list) 
O(1) or O(n)?



More information about the Python-list mailing list