[sage-devel] Re: Orderings and dictionaries

2013-05-14 Thread Nils Bruin
On May 14, 3:42 am, Jernej Azarija wrote: > This is what the guys on #python (IRC) told me to consider > > >>> d1 = {-1: 0, -2: 0}>>> d2 = {-2: 0, -1: 0}>>> d1{-2: 0, -1: 0}>>> d2{-1: > >>> 0, -2: 0}>>> d1 == d2True>>> d1.keys()[-2, -1]>>> d2.keys()[-1, -2]>>> That is an extremely sneaky example

[sage-devel] Re: Orderings and dictionaries

2013-05-14 Thread Nathann Cohen
d1 = {-1: 0, -2: 0} d2 = {-2: 0, -1: 0} d1 > {-2: 0, -1: 0} d2 > {-1: 0, -2: 0} d1 == d2 > True d1.keys() > [-2, -1] d2.keys() > [-1, -2] NOooo Ookokokokok. Then the code is good a

[sage-devel] Re: Orderings and dictionaries

2013-05-14 Thread Jernej Azarija
This is what the guys on #python (IRC) told me to consider >>> d1 = {-1: 0, -2: 0}>>> d2 = {-2: 0, -1: 0}>>> d1{-2: 0, -1: 0}>>> d2{-1: 0, >>> -2: 0}>>> d1 == d2True>>> d1.keys()[-2, -1]>>> d2.keys()[-1, -2]>>> On Tue, May 14, 2013 at 12:12 PM, Nathann Cohen wrote: > Hello everybody

[sage-devel] Re: Orderings and dictionaries

2013-05-14 Thread luisfe
No, you cannot. You should always think dictionaries as unordered structures. Dictionary keys depend not only on the keys themselves but on the operations performed on the dictionary. Take a simple case with hash collision: {{{ sage: A={} sage: B={} sage: A[hash('a')]=0 sage: A['a']=1 sage: B['a']