Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #74214

Re: [Python-Dev] == on object tests identity in 3.x

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'subject:: [': 0.04; 'languages,': 0.04; 'subject:Python': 0.06; 'nasty': 0.07; 'referring': 0.07; 'anders': 0.09; 'default.': 0.09; 'things,': 0.09; 'valueerror:': 0.09; 'python': 0.11; 'does,': 0.16; 'nan': 0.16; 'nans': 0.16; 'numpy': 0.16; 'subject:Dev': 0.16; 'subject:object': 0.16; 'tradeoffs': 0.16; 'wrote:': 0.18; '(but': 0.19; '>>>': 0.22; 'import': 0.22; 'error': 0.23; 'choices': 0.24; 'math': 0.24; 'handling': 0.26; 'header:In-Reply- To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; '"",': 0.31; '>>>>': 0.31; 'ctypes': 0.31; "d'aprano": 0.31; 'implied': 0.31; 'steven': 0.31; 'file': 0.32; 'skip:c 30': 0.32; '(most': 0.33; "can't": 0.35; 'received:google.com': 0.35; 'false': 0.36; 'e.g.': 0.38; 'presently': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'ian': 0.60; 'skip:n 10': 0.64; 'more': 0.64; 'different': 0.65; 'jul': 0.74
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=a6XBXQMJSLZ8uD3sng2+u0poEFWeizuVlGk7c+wF4d4=; b=G9RsesKZlN3/tjxUp76jK6EnQ2fiM1BQ9szj6XLsfhwwXsofk+0uyhGHhNVr9x0pI2 p8Ag9fNBl1TqZqhiCuc1zDECxtnl87eg+lw9sZm1u3kusvWwc7Nfdwdd/IXAa8gBDJTA ne5fr9zGV0PlTBXKAzUWY+XY5XnAPDIfz1oYEeWTVO+P2hT5r3R+XOmCgaCcLwOfcfH6 GXjlQc37wHOEWTtNV2k4467ZbniLNQpYdmw2dHneGvyH3yA7iWjpc/DWzM3QbAOXm7ln 8mXVilSEgu07HCYUhT7gk4tj3/Tk/nleSAa1gXaHmZPbXcUl6vaUfWpjh5oIYX9M2n3J 1U/w==
X-Received by 10.68.111.2 with SMTP id ie2mr27459830pbb.97.1404857185986; Tue, 08 Jul 2014 15:06:25 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <CALwzid=cgKrW2XYUvb2WGtJj8Z4SwcXfOHzTt0BT_hZ=AOU=sw@mail.gmail.com>
References <53BB2AC7.2060009@gmx.de> <53BB2F25.3020205@gmx.de> <53BB5082.500@btinternet.com> <20140708031202.GF13014@ando> <53BB6D5F.1010800@btinternet.com> <87a98ktjv7.fsf@uwakimon.sk.tsukuba.ac.jp> <CAPTjJmpvyvw81fY899mkuaui2d4u4dXr=2Vtz9z+JusOS=7DkA@mail.gmail.com> <8761j8thf5.fsf@uwakimon.sk.tsukuba.ac.jp> <20140708165745.GJ13014@ando> <53BC5053.1010904@jmunch.dk> <CALwzid=cgKrW2XYUvb2WGtJj8Z4SwcXfOHzTt0BT_hZ=AOU=sw@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Tue, 8 Jul 2014 16:05:45 -0600
Subject Re: [Python-Dev] == on object tests identity in 3.x
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.11665.1404857194.18130.python-list@python.org> (permalink)
Lines 32
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1404857194 news.xs4all.nl 2959 [2001:888:2000:d::a6]:54273
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:74214

Show key headers only | View raw


On Tue, Jul 8, 2014 at 3:53 PM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> On Tue, Jul 8, 2014 at 2:10 PM, Anders J. Munch <2014@jmunch.dk> wrote:
>> Steven D'Aprano wrote:
>>> - Keeping reflexivity for NANs would have implied some pretty nasty
>>>    things, e.g. if log(-3) == log(-5), then -3 == -5.
>>
>>
>>>>> log(-3)
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> ValueError: math domain error
>>
>> You were perhaps referring to the log functions in C and Fortran, not
>> math.log?
>> The tradeoffs are different in those languages, so choices the IEEE-754
>> committee made with C and Fortran in mind may be less relevant for Python.
>
>>>> import ctypes
>>>> libm = ctypes.cdll.LoadLibrary("libm.so.6")
>>>> log = libm.log
>>>> log.argtypes = [ctypes.c_double]
>>>> log.restype = ctypes.c_double
>>>> log(-3)
> nan
>>>> log(-5)
> nan
>>>> log(-3) == log(-5)
> False

Also, numpy provides more control over floating-point error handling
than straight Python does, and I think (but can't presently test) that
numpy.log(-3) will return nan by default.

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: [Python-Dev] == on object tests identity in 3.x Ian Kelly <ian.g.kelly@gmail.com> - 2014-07-08 16:05 -0600
  Re: [Python-Dev] == on object tests identity in 3.x Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-07-09 01:04 +0000

csiph-web