[Numpy-discussion] annoying numpy string to float conversion behaviour

Torgil Svensson torgil.svensson at gmail.com
Mon Jun 25 18:39:02 EDT 2007


On 6/25/07, Torgil Svensson <torgil.svensson at gmail.com> wrote:
> On 6/25/07, Robert Kern <robert.kern at gmail.com> wrote:
> > NaNs and infs are IEEE-754 concepts. Python does run on non-IEEE-754 platforms,
> > and I don't think that python-dev will want to entirely exclude them. You will
> > have to do *something* about those platforms. Possibly, they just won't support
> > NaNs and infs at all, but you'd have to make sure that the bit pattern that is a
> > NaN on IEEE-754 systems won't be misinterpreted as a NaN on the non-IEEE-754
> > systems.
>
> Sounds like some clever #ifdefs is needed here.

I took a quick glance at the python code. On the positive side there
is ways to detect if a platform is IEEE-754, they error out if special
values are unpacked to non IEEE-754 platforms (we can do the same on
strings). So far it looks straight forward.

The problem is what strings to expect, the string generation uses
OS-specific routines (probably the c-library, haven't looked).  I
think python should be consistent regarding this across platforms but
I don't know if different c-libraries generates different strings for
special numbers. Anyone? If it's true, this might go political (should
string representation follow the system or be unified) and
implementation should either be in OS-common code or OS-specific code.

//Torgil



More information about the NumPy-Discussion mailing list