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: 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: 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> <8761j8thf5.fsf@uwakimon.sk.tsukuba.ac.jp> <20140708165745.GJ13014@ando> <53BC5053.1010904@jmunch.dk> From: Ian Kelly Date: Tue, 8 Jul 2014 16:05:45 -0600 Subject: Re: [Python-Dev] == on object tests identity in 3.x To: Python 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Tue, Jul 8, 2014 at 3:53 PM, Ian Kelly 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 "", line 1, in >> 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.