A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2011-April/110963.html below:

[Python-Dev] PyObject_RichCompareBool identity shortcut

[Python-Dev] PyObject_RichCompareBool identity shortcutGlenn Linderman v+python at g.nevcal.com
Wed Apr 27 20:41:15 CEST 2011
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?
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4