Klaus Neuner wrote:
Hello,
what is the fastest way to determine whether list l (with
len(l)>3) contains a certain element?
If you can use a set or dict instead of a list this test will be much
faster.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
what is the fastest way to determine whether list l (with
len(l)>3) contains a certain element?
Either a sorted list (in conjunction with the bisect-module) or a
dictionary is your friend...
Regards,
Marco
--
http://mail.python.org/mailman/listinfo/python-list
Klaus Neuner <[EMAIL PROTECTED]> wrote:
> what is the fastest way to determine whether list l (with
> len(l)>3) contains a certain element?
"if thecertainelement in l:"
is the fastest way unless there are properties of l which you're not
telling us about, or unless what you need is not just
On Wed, 26 Jan 2005 06:45:29 -0800 (PST), Klaus Neuner
<[EMAIL PROTECTED]> wrote:
> what is the fastest way to determine whether list l (with
> len(l)>3) contains a certain element?
If the list isn't sorted, I doubt you'll do better than
if an_element in my_list:
# do whatever
If the lis