On Thu, 30 Nov 2006 18:59:32 -0800, David Harvey
<[EMAIL PROTECTED]> wrote:
>>> We got some of the way towards solving this problem at SAGE
>>> Days 2. Much of the work has been done for the Integer class. I hope
>>> that someone can put some effort into generalising and improving
>>> those efforts. I don't have the time right now to work on this.
>>
>> I pushed that same work through to most other compiled classes.
>> E.g., Python's own ints with their caching etc., do the benchmark
>> mentioned above in 0.70 seconds, so now SAGE's object creation isn't
>> that far off from Python's own built-in optimized object creation.
>
> I didn't realise that work had already been done. Thanks for doing that!
>
> It's really incredible that MAGMA goes faster than python ints here.
> From memory, at sage days 2, our Integer stuff was still a factor of
> 7-10 away from python ints, at least for addition.
Python ints:
(1) Have a custom optimized allocation scheme, which e.g., allocates
a block of 1000 ints all at once, then fills them in, then allocates
another such block when there are > 1000 ints all in use at once.
(2) it never returns any memory allocated for ints (saving it for
future ints).
In short, Python int creation is very fast partly because lots and lots
of caching is used, similar to the sort of caching that is being proposed
for Z/nZ.
It might be interesting to copy intobject.c from the Python source code
to some other file, and adapt it to use GMP ints as the underlying data
structure instead. I wonder what would happen? Did you consider doing
that at the coding sprint? (I'm not suggesting replacing Python's ints
by GMP ints, but making a new int type that happens to quickly benefit
from all the work that went into making the Python int type fast.)
William
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---