On 4/23/2010 2:21 PM Alan Gauld said...
"Emile van Sebille" <em...@fenx.com> wrote
It's expensive enough that for a list this size I'd convert it to a
dict and use in on that. eg,
a = range(100000)
d = dict(zip(a,a))
Surely that would depend on how often you do the search? If its a one
off occurence I'd expect the overhead of zipping and converting to a
dict would outweight the savings?
Oh sure, but in practical terms, if it's a one-off situation who cares
which you us? For a one-off I'd just use in and not be concerned.
If the search was inside a loop however then I'd definitely agree.
Although I'd opt for a set rather than a dict...
Old habits...
Emile
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor