Hack request: rational numbers

Tim Peters tim.one at home.com
Sat Jan 27 05:09:52 EST 2001


[Pearu Peterson and Michael Hudson, exchange exruciating ideas for
 making Python treat 3/4 as a rational, or add new 3r/4, r3/4, 3/4r
 literal synax]

[Pearu]
> 3) What are changes that these hooks will be accepted to Python core?

[Michael]
> Can't speak for the people whose opinions really count, but my
> guess: none.

You're learning to channel Guido!  It's giving me hope that I can retire
someday <wink>.

[Pearu]
> 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*).

Sorry, but that's exactly like thinking people want to prevent Python from
supporting business applications because it doesn't have

    $3.45

literals (along with 179 other national currency notations); and want to
prevent Python from supporting surveyors because it doesn't support a
literal notation for angles in units of grads; etc.

But note that Python doesn't support any notations especially warped toward
web or GUI programming, either.  Keyword arguments were added to Python
primarily to ease writing Tkinter apps, so that's a case where GUI
programming inspired a *generally* useful language addition.  I can't say
that the ellipsis object added for the NumPy folks has provided similarly
broad benefits.

It's safe to say that Guido isn't likely to add more language gimmicks of
use to only one domain, even if it's a domain he loves.  It's a
general-purpose programming language, after all.

Note too that Macsyma faced a similar (but worse) dilemma, trying to dream
up some way to make symbolic computation comfortable to mathematicians in a
Lisp system.  They did an obvious thing:  invented a brand new notation
warped toward their audience, and wrote a little compiler to convert it to
Lisp.  Probably good for beginners, but the deeper you got into it the more
you had to learn Lisp anyway.

That said, I believe your only hope of getting new literal syntax is to
embed it in a general proposal.  Some notation for rational literals is just
one of an unbounded number of similar desires.  Without a general scheme for
extending literal notations, there's also no hope of getting anyone to
update all the tools that parse Python either (thinking here of things like
tokenize.py, IDLE, pyclbr.py, the Emacs python-mode, etc -- not to mention
Jython).  The costs of adding new syntax are just too high unless it
benefits *all* users.

excluding-those-who-don't-like-anything-new-ever-ly y'rs  - tim





More information about the Python-list mailing list