A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-April/088482.html below:

[Python-Dev] slightly inconsistent set/list pop behaviour

[Python-Dev] slightly inconsistent set/list pop behaviourSteve Holden steve at holdenweb.com
Wed Apr 8 17:14:09 CEST 2009
Paul Moore wrote:
> 2009/4/8 Duncan Booth <duncan.booth at suttoncourtenay.org.uk>:
>> Andrea Griffini <gripho66 at gmail.com> wrote:
>>
>>> On Wed, Apr 8, 2009 at 12:57 PM, Jack diederich <jackdied at gmail.com>
>>> wrote:
>>>> You wrote a program to find the two smallest ints that would have a
>>>> hash collision in the CPython set implementation?  I'm impressed.
>>>>  And by impressed I mean frightened.
>>> ?
>>>
>>> print set([0,8]).pop(), set([8,0]).pop()
>> If 'smallest ints' means the sum of the absolute values then these are
>> slightly smaller:
>>
>>>>> print set([-1,6]).pop(), set([6,-1]).pop()
>> 6 -1
> 
> Can't resist:
> 
>>>> print set([-2,-1]).pop(), set([-1,-2]).pop()
> -1 -2
> 
>>> a = 0.001
>>> b = 0.002
>>> print set([a, b]).pop(), set([b, a]).pop()
0.002 0.001

Let's stop here ...

regards
 Steve
-- 
Steve Holden           +1 571 484 6266   +1 800 494 3119
Holden Web LLC                 http://www.holdenweb.com/
Watch PyCon on video now!          http://pycon.blip.tv/

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4