[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
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
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
[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
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')