David McKen cic_3_b at
Sun Jan 25 10:57:31 CET 2004

Pass by refrence would be my first suggestion especially if the
numbers are passed to alot of functions. That will cut down
tremendously on the number of temporary objects created.

Other than that maybe try using the mpz_realloc2 and related
functions to allocate the nessesary memory once to save future memory

The only other thing I can think of is the fact that some of the
functions can store their results in the same variable that was
passed in (mpz_abs is an example of such a funcion). Taking advantage
of these functions can probably speed things up a bit.

A decent bit of the info I have posted came from the efficiency
section in the gmp documentation (GMP basics -> Efficiency) maybe you
can find other ways to speed things up there.

--- lingwitt at wrote:
> In other words, how can I best eliminate the memory management for
> a 
> program that is producing a lot of temporary numbers?
> On 24 Jan 2004, at 5:10 PM, lingwitt at wrote:
> > More specifically, the time is spent doing memory management with
> > free() and malloc().
> >
> > On 24 Jan 2004, at 5:06 PM, lingwitt at wrote:
> >
> >> Before the C++ implementation was mature, I threw together my
> own 
> >> version in which I simply wrapped the C code in C++ code. The
> bulk of 
> >> the time that my programs spend is in calling constructors and 
> >> destructors, and I believe that it is really slowing down my
> program. 
> >> Is this a problem with my implementation and would it be best if
> I 
> >> used the official implementation? Excuse me if my question seems
> >> dull, but I don't fully understand the details. Thanks
> >
> > _______________________________________________
> > gmp-discuss mailing list
> > gmp-discuss at
> >
> >
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at

Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!

More information about the gmp-discuss mailing list