item access time: sets v. lists
Dennis.Benzinger at gmx.net
Wed Oct 4 18:22:38 CEST 2006
On Wed, 04 Oct 2006 16:02:56 GMT
"David Isaac" <aisaac0 at verizon.net> wrote:
> Is it expected for access to set elements to be much
> slower than access to list elements? Explanation?
> Alan Isaac
> >>> t1=timeit.Timer("for i in set(xrange(10000)):pass","")
> >>> t2=timeit.Timer("for i in list(xrange(10000)):pass","")
You're measuring the time for creating the xrange and the set/list too.
Create them before you call Timer() and repeat your timing.
More information about the Python-list