pickle and infinity

Bart Ogryczak B.Ogryczak at gmail.com
Thu Nov 30 09:31:46 EST 2006


Grant Edwards wrote:
> On 2006-11-29, Bart Ogryczak <B.Ogryczak at gmail.com> wrote:
> >
> > Fredrik Lundh wrote:
> >> Bart Ogryczak wrote:
> >>
> >> > I´ve got this problem with pickle, it seems it doesn´t handle
> >> > correctly infinite values (nor does Python return overflow/underflow
> >> > error).
> >>
> >> Python 2.X relies on the C library to serialize floats, and, as you've
> >> noticed, some C libraries can produce values that they themselves cannot
> >> read.
> >
> > Actually I´d be very happy, if Python would throw FloatPointExeption,
> > rather then allow infinite values.
>
> I'd be very unhappy.  I use both NaNs and infinities in many
> programs, so it needs to be selectable should that feature be
> added.

Like I´ve said. I´d be satisfied with something like fpectl, which
gives you option to either throw FloatPointExeption or go on with NaNs
and infs. NaNs and infinities are pain in the a** if you´re
integrating with C libraries or you´re using pickle, pyro, whatever.
The problem is, that the error pops out in the middle of the code that
really has nothing to do with the actual erroneous calculation. Its
impossible to trace back where the hell the NaN or infinite value comes
from.

> > Haven´t got idea how to do it. fpectl would do the trick, but
> > it´s not present nither on Solaris, nor on Windows platform.
> > And I´d need it on both.
>
> In my experience anything than needs to be portable and
> involves NaN, inf, or denormals is rather painful.

That´s not very comforting :-/




More information about the Python-list mailing list