Comparison between Python and "Ruby"
hniksic at srce.hr
Mon Nov 1 04:50:14 CET 1999
Dale Nagata <dnagata at creo.com> writes:
> Ian Clarke wrote:
> > * No way to automatically convert between long integer and small
> > integer.
> Python 1.5.1 (#0, Oct 14 1998, 20:14:21) [MSC 32 bit (Intel)] on win32
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> int(1L)
> >>> long(1)
That doesn't look "automatically" to me.
>>> sys.maxint + 1
Traceback (innermost last):
File "<stdin>", line 1, in ?
OverflowError: integer addition
>>> (long(sys.maxint) + 1) - 1
I've never seen Ruby so I don't know what it does, but in these cases
Lisp will do the right thing. Example using CLISP:
> (type-of most-positive-fixnum)
> (type-of (1+ most-positive-fixnum))
> (type-of (1- (1+ most-positive-fixnum)))
> (1+ 99999999999999999)
In Lisp, you can use fixnums (Python ints) and bignums (Python longs)
interchangeably. Which is a very nice feature.
More information about the Python-list