"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> A set, on the other hand, uses a hash table so finding an element
> takes constant time (it's one hash lookup, independent of the size of
> the set)--and determining an item isn't there is likewise constant
> time.
>
One hash calculation, but ther
"Duncan Booth" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> "Paul McGuire" <[EMAIL PROTECTED]> wrote:
>
>> By contrast, a set (and also the keys in a dict) use a tree structure
>> to index more quickly into the list of items
>
> 'dict' and I believe also 'set' use a hash table, no
"Neil Cerutti" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On 2006-10-04, Paul McGuire <[EMAIL PROTECTED]> wrote:
>> "Neil Cerutti" <[EMAIL PROTECTED]> wrote in message
>> news:[EMAIL PROTECTED]
>>
>
> It seems to be timing "testing for membership", not "random
> access". Random
David Isaac 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 be
On 2006-10-04, Paul McGuire <[EMAIL PROTECTED]> wrote:
> "Neil Cerutti" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>
>> Look at the code again. It's not testing what it says it's
>> testing.
>
> It isnt?
>
> The only quibble I can see is that there really is no "first"
> element
"Paul McGuire" <[EMAIL PROTECTED]> wrote:
> By contrast, a set (and also the keys in a dict) use a tree structure
> to index more quickly into the list of items
'dict' and I believe also 'set' use a hash table, not a tree structure.
--
http://mail.python.org/mailman/listinfo/python-list
"David Isaac" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 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
>>
"Neil Cerutti" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Look at the code again. It's not testing what it says it's
> testing.
>
It isnt?
The only quibble I can see is that there really is no "first" element in a
set. I picked the "0 in set" and "0 in list" to pick the fa
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.52208618693
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 questi
"David Isaac" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 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(1)):pass","")
t2=timeit.Timer("for i in
On Wed, 04 Oct 2006 16:02:56 GMT
"David Isaac" <[EMAIL PROTECTED]> wrote:
> 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(1)):pass","")
> >>> t2=timeit.Timer("for i
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(1)):pass","")
>>> t2=timeit.Timer("for i in list(xrange(1)):pass","")
>>> t1.timeit(1000)
9.806250235714316
>>> t2.timeit(1000
13 matches
Mail list logo