Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-21 Thread Adam Olsen
On Sun, Mar 21, 2010 at 16:59, Steven D'Aprano wrote: > If naive users are going to use the interpreter as a calculator, they're > going to start off using floats and ints simply because they require > less typing. My idea is to allow a gentle learning curve with Decimal > (and Fraction) without s

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-21 Thread Raymond Hettinger
On Mar 21, 2010, at 6:24 PM, Guido van Rossum wrote: > On Sun, Mar 21, 2010 at 4:16 PM, Raymond Hettinger > wrote: >> >> On Mar 21, 2010, at 3:59 PM, Steven D'Aprano wrote: >> >>> On Mon, 22 Mar 2010 06:31:57 am Raymond Hettinger wrote: I really like Guido's idea of a context flag to cont

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-21 Thread Guido van Rossum
On Sun, Mar 21, 2010 at 4:16 PM, Raymond Hettinger wrote: > > On Mar 21, 2010, at 3:59 PM, Steven D'Aprano wrote: > >> On Mon, 22 Mar 2010 06:31:57 am Raymond Hettinger wrote: >>> I really like Guido's idea of a context flag to control whether >>> mixing of decimal and binary floats will issue a w

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-21 Thread Raymond Hettinger
On Mar 21, 2010, at 3:59 PM, Steven D'Aprano wrote: > On Mon, 22 Mar 2010 06:31:57 am Raymond Hettinger wrote: >> I really like Guido's idea of a context flag to control whether >> mixing of decimal and binary floats will issue a warning. >> The default should be to issue the warning (because unl

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-21 Thread Raymond Hettinger
On Mar 21, 2010, at 3:50 PM, Greg Ewing wrote: > Raymond Hettinger wrote: > >> Since decimal also allows arbitrary sizes, all long ints can be >> exactly represented (this was even one of the design goals >> for the decimal module). > > There may be something we need to clarify here. I've been

Re: [Python-Dev] Decimal & amp; lt; -& amp; gt; float comparisons in py3k.

2010-03-21 Thread Greg Ewing
Steven D'Aprano wrote: Then they're in for a terrible, terrible disappointment. Rounding issues don't go away because you're using Decimal instead of float, No, but what I mean is that they prefer to be surprised in unsurprising ways, so to speak. Everyone knows that floating point numbers ha

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-21 Thread Steven D'Aprano
On Mon, 22 Mar 2010 06:31:57 am Raymond Hettinger wrote: > I really like Guido's idea of a context flag to control whether > mixing of decimal and binary floats will issue a warning. > The default should be to issue the warning (because unless > you know what you're doing, it is most likely an erro

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-21 Thread Raymond Hettinger
On Mar 21, 2010, at 3:35 PM, Guido van Rossum wrote: > >> It seems to me that Decimals and floats should be considered at >> the same level (i.e. both implement Real). > > Agreed, but doesn't help. (Except against the idea that Decimal goes > on the "integer" side of Fraction, which is just wron

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-21 Thread Greg Ewing
Raymond Hettinger wrote: The question of where to stack decimals in the hierarchy was erroneously being steered by the concept that both decimal and binary floats are intrinsically inexact. But that would be incorrect, inexactness is a taint, the numbers themselves are always exact. I don't

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-21 Thread Greg Ewing
Raymond Hettinger wrote: The question of where to stack decimals in the hierarchy was erroneously being steered by the concept that both decimal and binary floats are intrinsically inexact. But that would be incorrect, inexactness is a taint, the numbers themselves are always exact. I don't

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-21 Thread Greg Ewing
Raymond Hettinger wrote: Since decimal also allows arbitrary sizes, all long ints can be exactly represented (this was even one of the design goals for the decimal module). There may be something we need to clarify here. I've been imagining that the implicit conversions to Decimal that we're t

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-21 Thread Guido van Rossum
On Sun, Mar 21, 2010 at 11:25 AM, Raymond Hettinger wrote: > Right.  We should be guided by: >     fractions are a superset of decimals which are a superset of binary > floats. But mixed Fraction-float operations return floats, not Fractions. > And by: >     binary floats and decimal floats bot

Re: [Python-Dev] Decimal & amp; lt; -& amp; gt; float comparisons in py3k.

2010-03-21 Thread Steven D'Aprano
On Mon, 22 Mar 2010 08:47:53 am Greg Ewing wrote: > Nick Coghlan wrote: > > That's fine - binary floats *are* surprising. That's why Decimal > > exists in the first place. > > This argument could equally well be used the other way -- > someone using Decimal is doing so precisely because they > *don

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-21 Thread Greg Ewing
Raymond Hettinger wrote: Remember, the notion of inexactness is a taint, not an intrinsic property of a type. Even the Scheme numeric tower recognizes this. LIkewise, the decimal specification also spells-out this notion as basic to its design. I'm not sure it really does, otherwise every de

Re: [Python-Dev] [RELEASED] Python 3.1.2

2010-03-21 Thread Terry Reedy
On 3/21/2010 1:12 PM, Benjamin Peterson wrote: On behalf of the Python development team, I'm joyful to announce the second bugfix release of the Python 3.1 series, Python 3.1.2. Thanks for the work. This bug fix release fixes numerous issues found in 3.1.1, and is considered a production rele

Re: [Python-Dev] Decimal & amp; lt; -& amp; gt; float comparisons in py3k.

2010-03-21 Thread Greg Ewing
Nick Coghlan wrote: That's fine - binary floats *are* surprising. That's why Decimal exists in the first place. This argument could equally well be used the other way -- someone using Decimal is doing so precisely because they *don't* want to be surprised, in which case they would probably pre

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-21 Thread Raymond Hettinger
On Mar 21, 2010, at 11:50 AM, R. David Murray wrote: > On Sun, 21 Mar 2010 11:25:34 -0700, Raymond Hettinger > wrote: >> It seems to me that Decimals and floats should be considered at >> the same level (i.e. both implement Real). >> >> Mixed Decimal and float should coerce to Decimal because

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-21 Thread Adam Olsen
On Sun, Mar 21, 2010 at 00:58, Nick Coghlan wrote: > I don't actually mind either way - the pragmatic tower is about coding > convenience rather than numeric purity (and mixing Fractions and > Decimals in the same algorithm is somewhat nonsensical - they're > designed for two completely different

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-21 Thread R. David Murray
On Sun, 21 Mar 2010 11:25:34 -0700, Raymond Hettinger wrote: > It seems to me that Decimals and floats should be considered at > the same level (i.e. both implement Real). > > Mixed Decimal and float should coerce to Decimal because it can be > done losslessly. > > There is no need to embed a n

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-21 Thread Raymond Hettinger
On Mar 21, 2010, at 10:02 AM, Guido van Rossum wrote: > On Sun, Mar 21, 2010 at 9:53 AM, Guido van Rossum wrote: >> Which I still have to review. (Mark, if you're there, could you make a >> brief post here on the mathematical definition of the new hash you're >> proposing, and why it is both eff

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-21 Thread Raymond Hettinger
On Mar 20, 2010, at 9:40 PM, Greg Ewing wrote: > Mark Dickinson wrote: > >> Except that float is fixed-width (typically 53 bits of precision), >> while Decimal allows a user-specified, arbitrarily large, precision; > > Yes, but it still has *some* fixed limit at any given > moment, so the resul

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-21 Thread Raymond Hettinger
>> >> Note that this would involve adding mixed Fraction/Decimal arithmetic as >> well as Decimal/float arithmetic. > > Yes, that was my intention too. +1 > >> I placed Decimal to the left of >> Fraction to keep Decimal's dependencies clear and because Decimal -> >> Fraction conversions appe

[Python-Dev] [RELEASED] Python 3.1.2

2010-03-21 Thread Benjamin Peterson
On behalf of the Python development team, I'm joyful to announce the second bugfix release of the Python 3.1 series, Python 3.1.2. This bug fix release fixes numerous issues found in 3.1.1, and is considered a production release. The Python 3.1 version series focuses on the stabilization and opti

Re: [Python-Dev] Decimal & amp; lt; -& amp; gt; float comparisons in py3k.

2010-03-21 Thread Guido van Rossum
On Sat, Mar 20, 2010 at 11:59 PM, Nick Coghlan wrote: > Greg Ewing wrote: >> Nick Coghlan wrote: >> >>> Note that Antoine's point was that float("0.1") and >>> Decimal.from_float(0.1) should compare equal. >> >> That would mean that Decimal("0.1") != float("0.1"), which might be >> surprising to s

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-21 Thread Guido van Rossum
On Sun, Mar 21, 2010 at 9:53 AM, Guido van Rossum wrote: > Which I still have to review. (Mark, if you're there, could you make a > brief post here on the mathematical definition of the new hash you're > proposing, and why it is both efficient to compute and good (enough) > as a hash function?) N

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-21 Thread Guido van Rossum
On Sat, Mar 20, 2010 at 6:54 PM, Nick Coghlan wrote: > Guido van Rossum wrote: >> I think we should seriously reconsider allowing mixed arithmetic >> involving Decimal, not just mixed comparisons. > > I'm glad I'm not the only one that started wondering that. I > wasn't quite game enough to actual

[Python-Dev] Fwd: Broken link to download (Mac OS X)

2010-03-21 Thread webmaster
Hey all, This seems to happen whenever we do a new release (we've had a couple of emails to webmas...@python.org about it since 2.6.5 was released). The main download page for Python has a broken link for the Mac installer (because it hasn't been built yet I assume): http://python.org/do

Re: [Python-Dev] Decimal & amp; lt; -& amp; gt; float comparisons in py3k.

2010-03-21 Thread Nick Coghlan
Greg Ewing wrote: > Nick Coghlan wrote: > >> Note that Antoine's point was that float("0.1") and >> Decimal.from_float(0.1) should compare equal. > > That would mean that Decimal("0.1") != float("0.1"), which might be > surprising to someone who didn't realise they were mixing floats > and decima

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-21 Thread Nick Coghlan
Raymond Hettinger wrote: > > On Mar 20, 2010, at 6:54 PM, Nick Coghlan wrote: >> >> I suggest a 'linearised' numeric tower that looks like: >> >> int -> Decimal -> Fraction -> float -> complex > > Is that a typo? Shouldn't Decimal and float go between Fraction and > complex? > > The abstract nu