![]() |
Available news archives:
comp.lang.tcl
-
comp.lang.python
-
comp.security.firewalls
-
sci.crypt -
comp.lang.php -
comp.lang.javascript
|
|
comp.lang.python archiveRe: __eq__ on a dict
From: Steven D'Aprano <steve@REMOVETHIScyber.com.au>
Date: Tue Jul 12 2005 - 08:37:35 CEST
Replying to myself... how sad.
On Tue, 12 Jul 2005 15:41:46 +1000, Steven D'Aprano wrote:
> That wasn't clear from his post at all. If he had explained what he
On reading it, that came across more snarky than I intended. Sorry.
> Asking the right question helps. But not in this case, because comparison
However, I wasn't completely insane, since I came across this tidbit:
http://python.active-venture.com/ref/comparisons.html
"Mappings (dictionaries) compare equal if and only if their sorted (key,
with a footnote leading to this comment:
"Earlier versions of Python used lexicographic comparison of the sorted
I also suggested:
> My second thought was that comparison is implemented by first comparing
I certainly can't prove it, since my example pseudo-code fails even on the
In summary:
Equality of dicts is guaranteed. Two dicts are equal if and only if their
One gotcha is that some dicts are unordered:
py> {1:1j} < {1:2j}
but even that is special-cased up to the wazzoo:
py> {1:1j} < {1:1j}
-- Steven.Received on Thu Sep 29 16:53:40 2005 |