A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/attachments/20110427/cf13098a/attachment.html below:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#330033" bgcolor="#ffffff">
    On 4/27/2011 2:15 PM, Mark Dickinson wrote:
    <blockquote
      cite="mid:BANLkTi=Podj_ntfprqrA=apm8kBcbmVZkw@mail.gmail.com"
      type="cite">
      <pre wrap="">On Wed, Apr 27, 2011 at 7:41 PM, Glenn Linderman <a class="moz-txt-link-rfc2396E" href="mailto:v+python@g.nevcal.com">&lt;v+python@g.nevcal.com&gt;</a> wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">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.
</pre>
      </blockquote>
      <pre wrap="">
For infinities, there's no issue:  there are exactly two distinct
infinities (+inf and -inf), and they don't have any special properties
that affect membership tests.   Your float-keyed dict can contain both
+inf and -inf keys, or just one, or neither, in exactly the same way
that it can contain both +5.0 and -5.0 as keys, or just one, or
neither.

For nans, you *can* put multiple nans into a dictionary as separate


keys, but under the current rules the test for 'sameness' of two nan
keys becomes a test of object identity, not of bitwise equality.
Python takes no notice of the sign bits and 'payload' bits of a float
nan, except in operations like struct.pack and struct.unpack.  For
example:
</pre>
    </blockquote>
    Thanks, Mark, for the succinct description and demonstration.  Yes,
    only two Inf values, many possible NaNs.  And this is what I would
    expect.<br>
    <br>
    I would not, however expect the original case that was described:<br>
    &gt;&gt;&gt; nan = float('nan')
    <br>
    &gt;&gt;&gt; nan == nan
    <br>
    False
    <br>
    &gt;&gt;&gt; [nan] == [nan]
    <br>
    True                  # also True in tuples, dicts, etc.
    <br>
    <br>
  </body>
</html>

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