Re: A rational proposal

2004-12-22 Thread Nick Coghlan
Mike Meyer wrote: Actually, I suggested that: float() + Rational() returns float You're suggesting that the implicit conversion to float not happen here, and the user be forced to cast it to float? And you're saying Decimal does it that way.[ Yup. I had another look at PEP 327 (the section on impli

Re: A rational proposal

2004-12-22 Thread Mike Meyer
Nick Coghlan <[EMAIL PROTECTED]> writes: > Actually, I was misremembering how Decimal worked - it follows the rule you > suggest: > > float() + Decimal() fails with a TypeError > float() + float(Decimal()) works fine > > And I believe Decimal's __float__ operation is a 'best effort' kind of > thi

Re: A rational proposal

2004-12-22 Thread Nick Coghlan
Mike Meyer wrote: Well, you want to be able to add floats to rationals. The results shouldn't be rational, for much the same reason as you don't want to convert floats to rationals directly. I figure the only choice that leaves is that the result be a float. That and float(rational) should be the o

Re: A rational proposal

2004-12-21 Thread Mike Meyer
Nick Coghlan <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: >> I'm willing to do the work to get >> decimals working properly with it. > > Facundo's post reminded me of some of the discussion about the > interaction between floats and Decimal that went on when he was > developing the module that

Re: A rational proposal

2004-12-21 Thread Nick Coghlan
Mike Meyer wrote: I'm willing to do the work to get decimals working properly with it. Facundo's post reminded me of some of the discussion about the interaction between floats and Decimal that went on when he was developing the module that eventually made it into the standard library. Perhaps

Re: A rational proposal

2004-12-20 Thread Mike Meyer
[EMAIL PROTECTED] (Christopher A. Craig) writes: > I've been thinking about doing this for a while. cRat > (http://sf.net/projects/pythonic) already meets these qualifications > except that I need to add decimal support to it now that decimals are > in the language. I could rewrite the existing

Re: A rational proposal

2004-12-20 Thread François Pinard
[Batista, Facundo] > To convert a Decimal to Rational, [...] Hi, people. I am not closely following this thread and do not know if this has been discussed before. Sorry if I'm repeating known arguments... Decimal to Rational is easy. The interesting problem is how to best convert a float to R

RE: A rational proposal

2004-12-20 Thread Batista, Facundo
Title: RE: A rational proposal [Mike Meyer] #- Good point. Currently, objects now how to convert themselves to int, #- float and complex. Should Rational now how to convert itself to #- Decimal (and conversely, decimal now how to convert itself to #- Rational)? To convert a Decimal to

Re: A rational proposal

2004-12-20 Thread Dan Bishop
Mike Meyer wrote: > "John Roth" <[EMAIL PROTECTED]> writes: > > > "Mike Meyer" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > >> PEP: XXX > >> Title: A rational number module for Python ... > >> Rationals will mix with all other numeric types. When combined with an > >> integer

Re: A rational proposal

2004-12-20 Thread Bengt Richter
On Fri, 17 Dec 2004 21:29:52 -0600, Mike Meyer <[EMAIL PROTECTED]> wrote: >PEP: XXX >Title: A rational number module for Python >Version: $Revision: 1.4 $ >Last-Modified: $Date: 2003/09/22 04:51:50 $ >Author: Mike Meyer <[EMAIL PROTECTED]> >Status: Draft >Type: Staqndards >Content-Type: text/x-rst

Re: A rational proposal

2004-12-20 Thread Christopher A. Craig
I've been thinking about doing this for a while. cRat (http://sf.net/projects/pythonic) already meets these qualifications except that I need to add decimal support to it now that decimals are in the language. I could rewrite the existing code in Python (it's currently in C), but there are some v

Re: A rational proposal

2004-12-19 Thread Dave Benjamin
Hi Mike - Thanks for taking the time to put this together. In article <[EMAIL PROTECTED]>, Mike Meyer wrote: > - max(*args): return the largest of a list of numbers and self. > - min(*args): return the smallest of a list of numbers and self. I would strongly prefer either adapting the already bui

Re: A rational proposal

2004-12-19 Thread Fredrik Lundh
Raymond L. Buvel wrote: >> gmpy wraps GMP, which is covered by LGPL; therefore, gmpy itself is >> LGPL, and thus, sadly, cannot be included with python (otherwise, >> speaking as gmpy's author, I'd be glad to fix its design to meet your >> objections). > Since the LGPL was designed to allow propr

Re: A rational proposal

2004-12-19 Thread Raymond L. Buvel
Alex Martelli wrote: Raymond L. Buvel <[EMAIL PROTECTED]> wrote: Mike Meyer wrote: PEP: XXX Title: A rational number module for Python I think it is a good idea to have rationals as part of the standard distribution but why not base this on the gmpy module (https://sourceforge.net/projects/gmpy

Re: A rational proposal

2004-12-18 Thread Paul Rubin
[EMAIL PROTECTED] (Alex Martelli) writes: > gmpy wraps GMP, which is covered by LGPL; therefore, gmpy itself is > LGPL, and thus, sadly, cannot be included with python (otherwise, > speaking as gmpy's author, I'd be glad to fix its design to meet your > objections). There's no obstacle to includin

Re: A rational proposal

2004-12-18 Thread Alex Martelli
Raymond L. Buvel <[EMAIL PROTECTED]> wrote: > Mike Meyer wrote: > > PEP: XXX > > Title: A rational number module for Python > > > I think it is a good idea to have rationals as part of the standard > distribution but why not base this on the gmpy module > (https://sourceforge.net/projects/gmpy

Re: A rational proposal

2004-12-18 Thread Nick Coghlan
Mike Meyer wrote: max() and min() are already part of the standard library. Providing them as instance methods is quite irregular. They don't handle decimals or rationals. This is following the lead of the decimal package. As Tim pointed out - decimal has its own versions of max & min which conform

Re: A rational proposal

2004-12-18 Thread Terry Reedy
"Mike Meyer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >>> Title: A rational number module for Python >> 1. I would call this Not Necessary but Nice. Perhaps the time has come to include rationals in the Standard Library, given that its expansion will be a focus of the 2.5

Re: A rational proposal

2004-12-18 Thread Mike Meyer
Jp Calderone <[EMAIL PROTECTED]> writes: > They do handle decimals. They handle any object which define __cmp__, > or the appropriate rich comparison methods. That settles that. They're gone from the proposal. So is the method inverse, as that's simply 1/rational.

Re: A rational proposal

2004-12-18 Thread Tim Peters
[Jp Calderone] ... > The Decimal type seems to define min and max so that NaNs > can be treated specially, but I glean this understanding from only > a moment of reading decimal.py. Perhaps someone more well > informed can declare definitively the purpose of these methods. To conform to the sema

Re: A rational proposal

2004-12-18 Thread Jp Calderone
On Sat, 18 Dec 2004 12:40:04 -0600, Mike Meyer <[EMAIL PROTECTED]> wrote: >"John Roth" <[EMAIL PROTECTED]> writes: > > > "Mike Meyer" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > >> PEP: XXX > >> Title: A rational number module for Python > >> The ``Rational`` class shall defi

Re: A rational proposal

2004-12-18 Thread Jp Calderone
On Sat, 18 Dec 2004 12:29:10 -0600, Mike Meyer <[EMAIL PROTECTED]> wrote: >"Raymond L. Buvel" <[EMAIL PROTECTED]> writes: > > > Mike Meyer wrote: > >> PEP: XXX > >> Title: A rational number module for Python > > > > > > I think it is a good idea to have rationals as part of the standard > > distr

Re: A rational proposal

2004-12-18 Thread Mike Meyer
"John Roth" <[EMAIL PROTECTED]> writes: > "Mike Meyer" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> PEP: XXX >> Title: A rational number module for Python >> The ``Rational`` class shall define all the standard mathematical >> operations: addition, subtraction, multiplication,

Re: A rational proposal

2004-12-18 Thread Mike Meyer
"Raymond L. Buvel" <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: >> PEP: XXX >> Title: A rational number module for Python > > > I think it is a good idea to have rationals as part of the standard > distribution but why not base this on the gmpy module > (https://sourceforge.net/projects/gmpy)?

Re: A rational proposal

2004-12-18 Thread John Roth
"Mike Meyer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] PEP: XXX Title: A rational number module for Python Version: $Revision: 1.4 $ Last-Modified: $Date: 2003/09/22 04:51:50 $ Author: Mike Meyer <[EMAIL PROTECTED]> Status: Draft Type: Staqndards Content-Type: text/x-rst Created:

Re: A rational proposal

2004-12-18 Thread Raymond L. Buvel
Mike Meyer wrote: PEP: XXX Title: A rational number module for Python I think it is a good idea to have rationals as part of the standard distribution but why not base this on the gmpy module (https://sourceforge.net/projects/gmpy)? That module already provides good performance. However, it d

Re: A rational proposal

2004-12-17 Thread Fredrik Lundh
Mike Meyer wrote: > Last-Modified: $Date: 2003/09/22 04:51:50 $ > Created: 16-Dec-2004 > Post-History: 30-Aug-2002 playing with the time machine? -- http://mail.python.org/mailman/listinfo/python-list