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

2005-01-15 Thread Tim Peters
[Gonçalo Rodrigues] 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

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

2005-01-15 Thread Alan Gauld
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

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

2005-01-15 Thread Alan Gauld
GR len is actually a field in the underlying C object so len() is a GR constant (O(1)) and as-fast-as-it-can-be operation. TP ...n integers), but (ignoring the range() complication) there's no TP difference in O() behavior between the two. OK, The timbot's word is good enough for me, I won't

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

2005-01-15 Thread Tim Peters
[Alan Gauld] OK, The timbot's word is good enough for me, I won't bother looking at the code, I'll revert to my previous assumption! :-) It's educational to look at the code anyway wink. Here it is, from Python's listobject.c: static int list_length(PyListObject *a) { return

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

2005-01-14 Thread kumar s
Hi Danny: Thank you for your suggestion. I tried creating a dictionary of 'what' list and searched keys with has_key method and it is pretty fast. Thanks again. following is the piece of code. K cors = [] intr = [] for i in range(len(what)): ele = split(what[i],'\t')