item access time: sets v. lists

David Isaac aisaac0 at verizon.net
Wed Oct 4 12:02:56 EDT 2006


Is it expected for access to set elements to be much
slower than access to list elements?  Explanation?
Thanks,
Alan Isaac

>>> t1=timeit.Timer("for i in set(xrange(10000)):pass","")
>>> t2=timeit.Timer("for i in list(xrange(10000)):pass","")
>>> t1.timeit(1000)
9.806250235714316
>>> t2.timeit(1000)
3.9823075279120701





More information about the Python-list mailing list