On Sat, Dec 17, 2016 at 5:12 PM, Steve D'Aprano
wrote:
> On Sat, 17 Dec 2016 03:55 pm, Chris Angelico wrote:
>
>> More than that: the lists are searched in linear time, the binary
>> seach runs in logarithmic time, but the set lookup is constant time.
>> Doesn't matter how big your set is, you can
On Sat, 17 Dec 2016 03:55 pm, Chris Angelico wrote:
> More than that: the lists are searched in linear time, the binary
> seach runs in logarithmic time, but the set lookup is constant time.
> Doesn't matter how big your set is, you can test for membership with
> one hash lookup.
To be pedantic:
On Sat, Dec 17, 2016 at 3:44 PM, wrote:
>> python3 listsearch.py
> Python version: sys.version_info(major=3, minor=5, micro=2,
> releaselevel='final', serial=0)
> building hashes...
> sorting...
> creating set...
> Unsorted list: 1.7384763684627569
> Sorted: 9.248799958145042
> set: 1.461416129
On Friday, December 16, 2016 at 6:27:24 PM UTC-8, Chris Angelico wrote:
> On Sat, Dec 17, 2016 at 1:20 PM, wrote:
> > I thought this was curious behavior. I created a list of random-looking
> > strings, then made a sorted copy. I then found that using "in" to see if a
> > string exists in the
On Sat, Dec 17, 2016 at 1:20 PM, wrote:
> I thought this was curious behavior. I created a list of random-looking
> strings, then made a sorted copy. I then found that using "in" to see if a
> string exists in the sorted list took over 9 times as long!
>
My numbers replicate yours (though my