dict order

Lie Lie.1296 at gmail.com
Wed Jun 18 12:47:13 CEST 2008


On Jun 18, 4:22 pm, Robert Bossy <Robert.Bo... at jouy.inra.fr> wrote:
> Hi,
>
> I wish to know how two dict objects are compared. By browsing the
> archives I gathered that the number of items are first compared, but if
> the two dict objects have the same number of items, then the comparison
> algorithm was not mentioned.
>
> Note that I'm not trying to rely on this order. I'm building a
> domain-specific language where there's a data structure similar to
> python dict and I need an source of inspiration for implementing
> comparisons.
>
> Thanks
> RB

Why not consider them as equal, it's simple and is basically telling
people not to rely on them because one day A might be lower than B and
the other day, A and B that hasn't been modified at all might switch
sides without warning.

Or you could just use any arbitrary way of comparison (Python Zen: In
the face of ambiguity, refuse the temptation to guess.).



More information about the Python-list mailing list