Hack request: rational numbers

Michael Hudson mwh21 at cam.ac.uk
Fri Jan 26 08:32:18 EST 2001


Pearu Peterson <pearu at ioc.ee> writes:

> On 25 Jan 2001, Michael Hudson wrote:
> 
> > > is rather clumsy. Clearly, minimal representation of this rational number
> > > is
> > > 
> > >     3/4
> > > 
> > > but in Python this expression has different meaning.
> > 
[snip slightly silly bytecodehacks idea] 
> And it will break other codes/modules where `3/4' is expected to return
> `0'.

Yes, but won't your idea?  I'd admit I haven't thought too hard about
all this.

> And it will work only for interactive session, right?

You could write an import hook... that way you could have .pyr file
that have the different x/y behaviour, and the old behaviour in .py
files.

> So, I'll not going to do that either.

Fair enough.

> > > 3) What are changes that these hooks will be accepted to Python core?
> > 
> > Can't speak for the people whose opinions really count, but my guess: none.
> 
> It is rather disappointing estimation:(
> 
> And it makes me think that (some? most?) people want to keep Python
> usage only in web/gui based applications rather than extending its
> usage to scientific computing (both *numerical* and *symbolical*).

That's not what I said; I'd expect it to be rejected on the grounds of
being a non-intuitive and ugly syntax.  You can do scientific
computing in Python without your proposal (believe me!), and it's all
a cost/benefit tradeoff.  The cost is additional complexity.

I found Python to be too slow for my mathematical stuff, though (and
don't say NumPy!  Doesn't apply here).

OTOH, I can't think of the last time I seriously used a non-integer
number in a Python program (and that includes the mathematical stuff
alluded to above), so maybe I'm not the best person to judge...

Cheers,
M.

-- 
  Any form of evilness that can be detected without *too* much effort
  is worth it...  I have no idea what kind of evil we're looking for
  here or how to detect is, so I can't answer yes or no.
                                       -- Guido Van Rossum, python-dev



More information about the Python-list mailing list