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

2009-04-08 Thread Martin v. Löwis
> foo = set([1, 65537]) > foo.pop() >> 1 > foo = set([65537, 1]) > foo.pop() >> 65537 > > 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. Well, Mark is th

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

2009-04-08 Thread Paul Moore
2009/4/8 Steve Holden : > Paul Moore wrote: >> 2009/4/8 Duncan Booth : >>> Andrea Griffini wrote: >>> On Wed, Apr 8, 2009 at 12:57 PM, Jack diederich wrote: > You wrote a program to find the two smallest ints that would have a > hash collision in the CPython set implementation?

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

2009-04-08 Thread Steve Holden
Paul Moore wrote: > 2009/4/8 Duncan Booth : >> Andrea Griffini wrote: >> >>> On Wed, Apr 8, 2009 at 12:57 PM, Jack diederich >>> 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 impr

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

2009-04-08 Thread Paul Moore
2009/4/8 Duncan Booth : > Andrea Griffini wrote: > >> On Wed, Apr 8, 2009 at 12:57 PM, Jack diederich >> 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. >>

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

2009-04-08 Thread Duncan Booth
Andrea Griffini wrote: > On Wed, Apr 8, 2009 at 12:57 PM, Jack diederich > 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(

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

2009-04-08 Thread Andrea Griffini
On Wed, Apr 8, 2009 at 12:57 PM, Jack diederich 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() Andrea _

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

2009-04-08 Thread Steve Holden
Jack diederich wrote: > On Wed, Apr 8, 2009 at 2:44 AM, Mark Dickinson wrote: >> On Wed, Apr 8, 2009 at 7:13 AM, John Barham wrote: >>> If you play around a bit it becomes clear that what set.pop() returns >>> is independent of the insertion order: >> It might look like that, but I don't think th

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

2009-04-08 Thread Jack diederich
On Wed, Apr 8, 2009 at 2:44 AM, Mark Dickinson wrote: > On Wed, Apr 8, 2009 at 7:13 AM, John Barham wrote: >> If you play around a bit it becomes clear that what set.pop() returns >> is independent of the insertion order: > > It might look like that, but I don't think this is > true in general (a

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

2009-04-08 Thread Antoine Pitrou
Mark Dickinson gmail.com> writes: > > On Wed, Apr 8, 2009 at 7:13 AM, John Barham gmail.com> wrote: > > If you play around a bit it becomes clear that what set.pop() returns > > is independent of the insertion order: > > It might look like that, but I don't think this is > true in general (at l

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

2009-04-07 Thread Mark Dickinson
On Wed, Apr 8, 2009 at 7:13 AM, John Barham wrote: > If you play around a bit it becomes clear that what set.pop() returns > is independent of the insertion order: It might look like that, but I don't think this is true in general (at least, with the current implementation): >>> foo = set([1, 65

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

2009-04-07 Thread John Barham
Tennessee Leeuwenburg wrote: > Now, I know that sets aren't ordered, but... > > foo = set([1,2,3,4,5]) > bar = [1,2,3,4,5] > > foo.pop() will reliably return 1 > while bar.pop() will return 5 > > discuss :) As designed. If you play around a bit it becomes clear that what set.pop() returns is inde

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

2009-04-07 Thread Raymond Hettinger
[Tennessee Leeuwenburg ] Now, I know that sets aren't ordered, but... foo = set([1,2,3,4,5]) bar = [1,2,3,4,5] foo.pop() will reliably return 1 while bar.pop() will return 5 discuss :) If that's what you need: http://code.activestate.com/recipes/576694/ Raymond __

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

2009-04-07 Thread Tennessee Leeuwenburg
Now, I know that sets aren't ordered, but... foo = set([1,2,3,4,5]) bar = [1,2,3,4,5] foo.pop() will reliably return 1 while bar.pop() will return 5 discuss :) Cheers, -T ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailma