On 4/27/2011 8:31 AM, Nick Coghlan wrote:
What that means is that "correct" implementations of methods like
__contains__, __eq__, __ne__, index() and count() on containers should
be using "x is y or x == y" to enforce reflexivity, but most such code
does not (e.g. our own collections.abc.Sequence implementation gets
those of these that it implements wrong, and hence Sequence based
containers will handle NaN in a way that differs from the builtin
containers)

+1 to everything Nick said.

One issue that I don't fully understand: I know there is only one instance of None in Python, but I'm not sure where to discover whether there is only a single, or whether there can be multiple, instances of NaN or Inf. The IEEE 754 spec is clear that there are multiple bit sequences that can be used to represent these, so I would hope that there can be, in fact, more than one value containing NaN (and Inf).

This would properly imply that a collection should correctly handle the case of storing multiple, different items using different NaN (and Inf) instances. A dict, for example, should be able to hold hundreds of items with the index value of NaN.

The distinction between "is" and "==" would permit proper operation, and I believe that Python's "rebinding" of names to values rather than the copying of values to variables makes such a distinction possible to use in a correct manner.

Can someone confirm or explain this issue?
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to