On 2006-10-04, David Isaac <[EMAIL PROTECTED]> wrote:
> Paul M. wrote:
>> Random access to item in list/set when item exists
>> set  -> 0.000241650824337
>> list -> 0.0245168031132
>>
>> Random access to item in list/set when item does not exist
>> set  -> 0.000187733357172
>> list -> 0.522086186932
>
>
> OK, that's a much better set of answers
> including to questions I did not
> even know I wanted to ask until
> I saw your post.  But, how to
> explain the above??

Look at the code again. It's not testing what it says it's
testing.

print "\nRandom access to first item in list/set"
t1=timeit.Timer("0 in z","z = set(xrange(10000))")
t2=timeit.Timer("0 in z", "z = list(xrange(10000))")
print "set  ->", t1.timeit(1000)
print "list ->", t2.timeit(1000)

print "\nRandom access to item in list/set when item exists"
t1=timeit.Timer("500 in z","z = set(xrange(10000))")
t2=timeit.Timer("500 in z", "z = list(xrange(10000))")
print "set  ->", t1.timeit(1000)
print "list ->", t2.timeit(1000)

-- 
Neil Cerutti
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to