[Tutor] Faster procedure to filter two lists . Please help
Gonçalo Rodrigues
op73418 at mail.telepac.pt
Sat Jan 15 19:11:56 CET 2005
Alan Gauld wrote:
> By missing out a loop(*) and some splits it should speed up
> significantly for the cost of some small added complexity in building
> the dictionaries in the first case.
>
> (*)In fact 3 loops because you aren't doing len() which effectively
> loops over the collection too.
>
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.
Best regards,
G. Rodrigues
More information about the Tutor
mailing list