[Python-Dev] PyObject_RichCompareBool identity shortcut

Alexander Belopolsky alexander.belopolsky at gmail.com
Thu Apr 28 08:51:07 CEST 2011


On Thu, Apr 28, 2011 at 2:20 AM, Glenn Linderman <v+python at g.nevcal.com> wrote:
..
> In that bug, Nick, you mention that reflexive equality is something that
> container classes rely on in their implementation.  Such reliance seems to
> me to be a bug, or an inappropriate optimization, ..

An alternative interpretation would be that it is a bug to use NaN
values in lists.  It is certainly nonsensical to use NaNs as keys in
dictionaries and that reportedly led Java designers to forgo the
nonreflexivity of nans:

"""
A "NaN" value is not equal to itself. However, a "NaN" Java "Float"
object is equal to itself. The semantic is defined this way, because
otherwise "NaN" Java "Float" objects cannot be retrieved from a hash
table.
""" - http://www.concentric.net/~ttwang/tech/javafloat.htm

With the status quo in Python, it may only make sense to store NaNs in
array.array, but not in a list.


More information about the Python-Dev mailing list