[Python-ideas] Make max() stable
David Mertz
mertz at gnosis.cx
Tue Jan 21 22:36:35 CET 2014
Oh yeah, this has been my bête noire for a long time. I think I first
mentioned this in 2003 at:
https://mail.python.org/pipermail/python-list/2003-March/205446.html
Then later in an IBM developerWorks article in 2005:
http://gnosis.cx/publish/programming/charming_python_b25.html
(the URL for the IBM version seems to have gone 404).
I do know why things are as they are and how to work with them... but hey,
at least it let me coin the phrase "Incomparable abominations" which I am
still rather proud of.
On Tue, Jan 21, 2014 at 1:21 PM, Chris Angelico <rosuav at gmail.com> wrote:
> On Wed, Jan 22, 2014 at 8:11 AM, David Mertz <mertz at gnosis.cx> wrote:
> > But this is just a question of inequality versus identity and that sets
> and
> > dictionaries are, IMO, too sloppy about that. That is, they behave
> exactly
> > as documented and as the BDFL has decreed, but I still feel uneasy about:
> >
> > >>> a = {1, 1+0j, 2}
> > >>> b = {1+0j, 1, 2}
> > >>> a
> > {(1+0j), 2}
> > >>> b
> > {1, 2}
> > >>> a == b
> > True
>
> This is because Python's made the decision that an int, a float, and a
> complex, representing the same number, should compare equal. I
> personally think they shouldn't (partly because it implies that
> they're all in some sort of tower, where the higher types can
> represent the lower types perfectly, and can perfectly represent that
> there's no further information - true of (float, complex) but not of
> (int, float), and it leads to problems with large integers), but it's
> a decision that's been made, and sets/dicts have to follow that. With
> small numbers, it just means that there's an identity-vs-value
> distinction (1 == 1.0 == 1+0j, but they're not is-identical), and sets
> have always had and will always have that issue.
>
> ChrisA
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
--
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons. Intellectual property is
to the 21st century what the slave trade was to the 16th.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140121/3dca4daf/attachment.html>
More information about the Python-ideas
mailing list