Python2 distutils question: how to best "autoconfig"...?

Alex Martelli aleaxit at yahoo.com
Mon Dec 11 14:55:19 EST 2000


"Tim Peters" <tim.one at home.com> gives me excellent advice...:

> > The specific issue is "how many bits of significance
> > does a Python float have".  (Or is there somewhere in
> > the Python headers a #define for this that I missed...?)
>
> You can use DBL_MANT_DIG from the platform's float.h.  Try hard to ignore
> FLT_RADIX <wink>.

*Wak!*  Shame on me.  How *COULD* I forget we can
now use Standard ISO C...!-(

> *Python*, though, no optimizer known to human-kind is smart enough to keep
> your temps in Pentium extended registers across being stored into PyFloat
> objects.  For example, I use this:

Good point (and, another brainstorm on my part!-).  But I think
DBL_MANT_DIG will do me.


> Alternative:  by hook or by crook, cut your double x back to storage
> precision (see above).  Say two successive convergents are i/j and i'/j'.
> Stop, and return i/j, when abs(double(i)/j - x) <= abs(double(i')/j' - x),
> i.e. stop when the convergents stop improving in double arithmetic.

That would rather frustrate the general purpose of the Stern-Brocot
thingy (which is also used to convert to mpq from unlimited-precision
mpf's).  But maybe it could be worth (speedier, &c) having two copies
of the algorithm in the module -- one implemented in, and used for,
Python floats, and a separate one for mpf's.  gmpy's still pre-alpha, so
I'm not pushing on performance all that much, yet, but I'll keep it in
mind for the future.


Alex



__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com




More information about the Python-list mailing list