[Tutor] Faster procedure to filter two lists . Please help

Alan Gauld alan.gauld at freenet.co.uk
Sun Jan 16 01:41:17 CET 2005


> It this correct? Python lists are not linked-lists (as in Scheme,
for
> example). They are more like arrays (or vectors in C++/Java) with a
> little more sofistication built into them to allow, for example, to
> amortize over time a sequence of append operations. But in a
nutshell,
> len is actually a field in the underlying C object so len() is a
> constant (O(1)) and as-fast-as-it-can-be operation.
>
> Someone correct me, please, If I'm wrong.

I thought that too, but after a recent thread when I said
the same I got an off list mail assuring me that len() was
calculated at run time by iterating over the collection!

I guess I should go and look at the code!
However in either case missing out the two function calls
to len() would help improve the speed...

Alan G.



More information about the Tutor mailing list