Received: by 10.180.84.234 with SMTP id c10mr103635wiz.4.1349753940448; Mon, 08 Oct 2012 20:39:00 -0700 (PDT) X-BeenThere: python-ideas@googlegroups.com Received: by 10.180.76.178 with SMTP id l18ls8757580wiw.4.canary; Mon, 08 Oct 2012 20:39:00 -0700 (PDT) Received: by 10.180.75.197 with SMTP id e5mr105495wiw.1.1349753940383; Mon, 08 Oct 2012 20:39:00 -0700 (PDT) Received: by 10.180.75.197 with SMTP id e5mr105492wiw.1.1349753940360; Mon, 08 Oct 2012 20:39:00 -0700 (PDT) Return-Path: Received: from mail.python.org (mail.python.org. [82.94.164.166]) by gmr-mx.google.com with ESMTPS id k11si1352861wiv.0.2012.10.08.20.39.00 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 08 Oct 2012 20:39:00 -0700 (PDT) Received-SPF: pass (google.com: domain of python-ideas-bounces+python-ideas-garchive-35620=googlegroups....@python.org designates 82.94.164.166 as permitted sender) client-ip=82.94.164.166; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of python-ideas-bounces+python-ideas-garchive-35620=googlegroups....@python.org designates 82.94.164.166 as permitted sender) smtp.mail=python-ideas-bounces+python-ideas-garchive-35620=googlegroups....@python.org; dkim=pass header...@python.org Received: from albatross.python.org (localhost [127.0.0.1]) by mail.python.org (Postfix) with ESMTP id 3XbPLX0zWXzQvZ for ; Tue, 9 Oct 2012 05:39:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=python.org; s=200901; t=1349753940; bh=LKU3WVB7zlcEWjFPskbpOMIL4hJhSS+p4BzkBP0unPA=; h=MIME-Version:In-Reply-To:References:Date:Message-ID:From:To:Cc: Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help: List-Subscribe:Content-Type:Content-Transfer-Encoding:Sender; b=dUYCNVjTtW7iTlgqxAptBM6hoHrPwIHsA4BIajeWAMtkZaRpYb6H+vcpTHoKiUCZF NedOuM66X4duBIW8lP/+/r4+LXB0pMI3EFwCyQpbjzV72t5L7PKhFaPVZSwFVrznde 2woiTmOFDN+l3lM7d3bU62DnzNlbGfWQWPo/xOow= X-Original-To: python-id...@python.org Delivered-To: python-id...@mail.python.org Received: from albatross.python.org (localhost [127.0.0.1]) by mail.python.org (Postfix) with ESMTP id 3XbPKf2xd4zP5R for ; Tue, 9 Oct 2012 05:38:14 +0200 (CEST) X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.03; 'subject:Python': 0.05; 'context': 0.05; 'guido': 0.05; 'svn': 0.05; 'rossum': 0.09; '(when': 0.16; 'alexander': 0.16; 'bugs.': 0.16; 'exceptions.': 0.16; 'maintainer': 0.16; 'nan': 0.16; 'oct': 0.16; 'subject:ideas': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'examples': 0.18; '>>>': 0.18; 'subject:] ': 0.19; 'import': 0.21; '"",': 0.22; 'context.': 0.22; 'default,': 0.22; 'cc:2**0': 0.23; 'raise': 0.24; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; '(most': 0.27; 'implemented': 0.27; 'library.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'comparison': 0.29; 'decimal': 0.29; 'division': 0.29; 'url:mailman': 0.29; 'url:code': 0.29; 'van': 0.29; "i'm": 0.29; 'mode': 0.30; 'returned': 0.30; 'point': 0.31; 'url:python': 0.32; 'file': 0.32; 'url:listinfo': 0.32; 'received:74.125.82': 0.33; 'traceback': 0.33; 'zero': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'false': 0.35; 'pm,': 0.35; 'similar': 0.35; 'skip:_ 40': 0.35; 'but': 0.36; 'received:74.125': 0.36; 'url:org': 0.36; 'skip:g 30': 0.36; 'email addr:python.org': 0.36; 'should': 0.36; 'some': 0.38; 'where': 0.40; 'subject:-': 0.40; 'header:Received:5': 0.40; 'url:mail': 0.40; 'think': 0.40; 'skip:u 10': 0.60; 'first': 0.61; 'url:p': 0.63; 'introduce': 0.80; 'experiment': 0.84; 'subject:before': 0.84 Received: from localhost (HELO mail.python.org) (127.0.0.1) by albatross.python.org with SMTP; 09 Oct 2012 05:38:14 +0200 Received: from mail-wg0-f42.google.com (mail-wg0-f42.google.com [74.125.82.42]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mail.python.org (Postfix) with ESMTPS for ; Tue, 9 Oct 2012 05:38:14 +0200 (CEST) Received: by mail-wg0-f42.google.com with SMTP id fm10so2409383wgb.1 for ; Mon, 08 Oct 2012 20:38:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=VB7oT4X2oCteSDbVl1DQzeGIoZpOltS+kl9UE0f2ioE=; b=NBIj9EuBeG1aN3bTvsjowMxET+NwFmLVKZ680RtDGJkdDffdK7niF1gzJuWGIL+hl6 yn4uzWJ+c0FNxlNoGgMF4c+ByOTAlTks0eCsXj65B25Akk+3m87ZxrIRXSVJfyP6xWHm Z8jbdV78BiUYxmj4Gj1IzEwnfTQaAf+DeOMdu9KveRyqDuaPE0VBCNa6D0OyM6MMTEKS Jr5IJTVwBa1/EonJK3Kr0CGzfijo017/SOYn/1OVpd/vDn8JiOvD7oJgaSEAsT7ZR0Vl YEyv2/jhHvc0Vu0QNxBR5gNbyuU3e66vWnyHxktBDuICGfyD6tqPHTZEzmEXKgNG/wYt Jdcg== MIME-Version: 1.0 Received: by 10.180.91.71 with SMTP id cc7mr1269859wib.2.1349753893743; Mon, 08 Oct 2012 20:38:13 -0700 (PDT) Received: by 10.223.152.197 with HTTP; Mon, 8 Oct 2012 20:38:13 -0700 (PDT) In-Reply-To: References: <506D94EE.30...@pearwood.info> <50723BE5.3060...@nedbatchelder.com> <507243D2.8000...@btinternet.com> <50736983.5030...@canterbury.ac.nz> Date: Mon, 8 Oct 2012 20:38:13 -0700 Message-ID: From: Case Van Horsen To: Alexander Belopolsky Cc: python-id...@python.org Subject: Re: [Python-ideas] checking for identity before comparing built-in objects X-BeenThere: python-id...@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Discussions of speculative Python language ideas List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: python-ideas-bounces+python-ideas-garchive-35620=googlegroups....@python.org Sender: "Python-ideas" On Mon, Oct 8, 2012 at 6:37 PM, Alexander Belopolsky wrote: > On Mon, Oct 8, 2012 at 9:07 PM, Guido van Rossum wrote: >> If we want to do *anything* I think we should first introduce a >> floating point context similar to the Decimal context. Then we can >> talk. > > +float('inf') I implemented a floating point context manager for gmpy2 and the MPFR floating point library. By default, it enables a non-stop mode where infinities and NaN are returned but you can also raise exceptions. You can experiment with gmpy2: http://code.google.com/p/gmpy/ Some examples >>> import gmpy2 >>> gmpy2.get_context() context(precision=53, real_prec=Default, imag_prec=Default, round=RoundToNearest, real_round=Default, imag_round=Default, emax=1073741823, emin=-1073741823, subnormalize=False, trap_underflow=False, underflow=False, trap_overflow=False, overflow=False, trap_inexact=False, inexact=False, trap_invalid=False, invalid=False, trap_erange=False, erange=False, trap_divzero=False, divzero=False, trap_expbound=False, allow_complex=False) >>> gmpy2.log(0) mpfr('-inf') >>> gmpy2.get_context() context(precision=53, real_prec=Default, imag_prec=Default, round=RoundToNearest, real_round=Default, imag_round=Default, emax=1073741823, emin=-1073741823, subnormalize=False, trap_underflow=False, underflow=False, trap_overflow=False, overflow=False, trap_inexact=False, inexact=False, trap_invalid=False, invalid=False, trap_erange=False, erange=False, trap_divzero=False, divzero=True, trap_expbound=False, allow_complex=False) >>> gmpy2.get_context().clear_flags() >>> gmpy2.get_context().trap_divzero=True >>> gmpy2.log(0) Traceback (most recent call last): File "", line 1, in gmpy2.DivisionByZeroError: 'mpfr' division by zero in log() >>> gmpy2.set_context(gmpy2.context()) >>> gmpy2.nan()==gmpy2.nan() False >>> gmpy2.get_context() context(precision=53, real_prec=Default, imag_prec=Default, round=RoundToNearest, real_round=Default, imag_round=Default, emax=1073741823, emin=-1073741823, subnormalize=False, trap_underflow=False, underflow=False, trap_overflow=False, overflow=False, trap_inexact=False, inexact=False, trap_invalid=False, invalid=False, trap_erange=False, erange=True, trap_divzero=False, divzero=False, trap_expbound=False, allow_complex=False) >>> gmpy2.get_context().trap_erange=True >>> gmpy2.nan()==gmpy2.nan() Traceback (most recent call last): File "", line 1, in gmpy2.RangeError: comparison with NaN >>> Standard disclaimers: * I'm the maintainer of gmpy2. * Please use SVN or beta2 (when it is released) to avoid a couple of embarrassing bugs. :( > _______________________________________________ > Python-ideas mailing list > Python-id...@python.org > http://mail.python.org/mailman/listinfo/python-ideas _______________________________________________ Python-ideas mailing list Python-id...@python.org http://mail.python.org/mailman/listinfo/python-ideas