[issue1580] Use shorter float repr when possible
report at bugs.python.org
Thu Feb 26 11:14:09 CET 2009
Mark Dickinson <dickinsm at gmail.com> added the comment:
> The GNU library's float<->string routines are based on David Gay's.
> Therefore you can compare those to Gay's originals
> (which accounts for the extreme length and complexity of Gay's code).
Looking at the code, I'm actually not seeing *extreme* complexity.
There are a lot of ifdefs for things that Python probably doesn't
care about (e.g., worrying about whether the inexact and underflow
flags get set or not; hexadecimal floats, which Python already has
its own code for; weird rounding modes, ...). There's some pretty
standard looking bignum integer stuff (it might even be possible to
substitute PyLong arithmetic for this bit). There's lots of boring
material for things like parsing numeric strings. The really
interesting part of the code is probably only a few hundred lines.
I think it looks feasible to adapt Gay's code for Python. I'm not sure
I'd want to adapt it without understanding it fully, but actually that
looks quite feasible too.
The x87 control word stuff isn't really a big problem: it can be dealt
with. The bit I don't know how to do here is using the autoconf
machinery to figure out whether the x87 FPU exists and is in use on a
particular machine. (I put in an autoconf test for x87-related double
rounding recently, which should be a pretty reliable indicator, but that
still fails if someone's already set 53-bit rounding precision...).
A side-note: for x86/x86_64, we should really be enabling SSE2 by
default whenever possible (e.g., on all machines newer than Pentium 3).
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list