On Jan 22, 2008 11:48 PM, Paul Zimmermann <[EMAIL PROTECTED]> wrote:
> thank you for your explanations.
>
> > The 'int' (and its bignum counterpart, 'long') are native Python
> > types.  As far as I know, we don't modify Python at all; removing
> > 'int' would be major surgery, and we're not going to do it.
> >
> > 'Integer' is a Sage type.  This means it has lots of useful
> > mathematical convenience methods (like .is_square()), it participates
> > in the coercion model, etc.  Also, 'Integer' is implemented with GMP,
> > and 'long' is not, so 'Integer' is much faster for large numbers.
>
> Would it be possible to extend long by new methods like is_square, and get
> rid of Integer?

No, not without changing Python.  The semantics of the two types are almost
totally different.     As Carl Witty explained, having these two
distinct long integer
types is part of the "price" we pay by using an unmodified Python
interpreter for
Sage.   The benefit is that we immediately are working with a language that
has *millions* of users, and huge standard library, and very powerful packages
available such as numpy, scipy, twisted etc.   I think the pros more
than outweigh
the cons, though it won't be surprising of people disagree with me -- after all
every other popular computer algebra system besides Sage reinvents its own
language.

> I guess 'long' is based on GMP too, does it make sense to have two concurrent
> interfaces to GMP integers?
> Paul Zimmermann

long is _not_ based on GMP.   long is implemented from scratch in C by the
Python developers.   It is completely independent from GMP, and has much
different performance characteristics, storage formats, etc.

On Jan 23, 2008 5:18 AM, pgdoyle <[EMAIL PROTECTED]> wrote:
> Why does Python not use the GMP routines for long integers, if they
> are so much faster?

Despite it's huge standard library, Python is relative easy to build
from source on a huge
range of architectures -- e.g., a full Python interpreter is installed
on my iphone; there
was one on my plam treo before.     GMP is far more difficult to
build.    I think that's
the core reason why Python does not use GMP, and it's a really good
one.   Also, keep
in mind that very fast arbitrary precision integer arithmetic is
hardly relevant for 99.9999%
of Python applications (text processing, networking, quick and dirty
GUI's), and Python
longs aren't that bad when the integer size isn't too big.

-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to