Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!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.033 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'operator': 0.03; 'subject:Python': 0.06; 'float': 0.07; 'pep': 0.09; 'subject:Why': 0.09; '238': 0.16; 'arbitrarily': 0.16; 'floats;': 0.16; 'operation,': 0.16; 'sat,': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'fraction': 0.24; 'mathematical': 0.24; 'math': 0.24; 'regardless': 0.24; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'chris': 0.29; 'am,': 0.29; 'raise': 0.29; 'message-id:@mail.gmail.com': 0.30; '(which': 0.31; 'decimal': 0.31; 'division': 0.31; 'something': 0.35; 'case,': 0.35; 'received:google.com': 0.35; 'acceptable': 0.36; 'useful': 0.36; 'possible': 0.36; 'subject:?': 0.36; 'should': 0.36; 'two': 0.37; 'branch': 0.38; 'generic': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'use.': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'ian': 0.60; 'range': 0.61; 'simple': 0.61; "you're": 0.61; 'more': 0.64; 'different': 0.65; 'within': 0.65; '20,': 0.68; 'importantly,': 0.68; 'divide': 0.84; 'cast': 0.91 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=4TZBhyeng6JeqJgP8ODnSB4/jdGfR78P/mkhqrWPjQE=; b=V2wzXBLgiWg+9XTYllOVZet+eZzEC4mNxUhKutGhr4a/GI4QCZ/CVB0T0bwAN5z+Il bxvOusjRX6pBESRv98fCOis2hthBjNYz2pttoqCCLw09HaSY+s2GLG3rrkXm15w/9X93 yV9EKRbuDMikDyA2p46DpS73s3du290VWOhfY47aOaJ412Ptekqcn3KPM32Txsrquy5u TTLQZOLHU1M2sN32pafeNCbwvFj/aBEV+AKJuYzSeEcBl+Pj19arEIhXDMahqpZQfd99 AwfrdFEvlSf1USubE6uyIku1Lq0pjs1Dya3IGl8ZnSbXoS+0dKC6gx2HAebxG/e48uw7 soaA== X-Received: by 10.66.221.99 with SMTP id qd3mr29522228pac.46.1397939955292; Sat, 19 Apr 2014 13:39:15 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <7x8ur1esa5.fsf@ruckus.brouhaha.com> From: Ian Kelly Date: Sat, 19 Apr 2014 14:38:35 -0600 Subject: Re: Why Python 3? 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1397939964 news.xs4all.nl 2850 [2001:888:2000:d::a6]:34678 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:70398 On Sat, Apr 19, 2014 at 2:31 PM, Chris Angelico wrote: > On Sun, Apr 20, 2014 at 5:58 AM, Ian Kelly wrote: >> Considering that Fraction and Decimal did not exist yet, what type do >> you think the PEP 238 implementers should have chosen for the result >> of dividing two ints? If float is not acceptable, and int is not >> acceptable (which was the whole point of the PEP), then the only >> alternative I can see would have been to raise a TypeError and force >> the user to upcast explicitly. In that case, dividing arbitrary ints >> using floating-point math would not be possible for those ints that >> are outside the range of floats; you would get OverflowError on the >> upcast operation, regardless of whether the result of division would >> be within the range of a float. >> >>> Yes, I can see that it's nice for simple interactive use. >> >> More importantly, it's useful for implementers of generic mathematical >> routines. If you're passed arbitrary inputs, you don't have to check >> the types of the values you were given and then branch if both of the >> values you were about to divide happened to be ints just because the >> division operator arbitrarily does something different on ints. > > Or you just cast one of them to float. That way you're sure you're > working with floats. Which is inappropriate if the type passed in was a Decimal or a complex.