Re: pickle broken: can't handle NaN or Infinity under win32

2005-07-05 Thread Michael Hudson
Terry Reedy [EMAIL PROTECTED] writes: Grant Edwards [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I'm working on it. I should have said it's trivial if you have access to the platforms to be supported. I've tested a fix that supports pickle streams generated under Win32 and

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-23 Thread Steven D'Aprano
On Thu, 23 Jun 2005 00:11:20 -0400, Tim Peters wrote: Well, I try, Ivan. But lest the point be missed wink, 754 doesn't _want_ +0 and -0 to act differently in almost any way. The only good rationale I've seen for why it makes the distinction at all is in Kahan's paper Branch Cuts for

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-23 Thread Tim Peters
[Tim Peters'] Well, I try, Ivan. But lest the point be missed wink, 754 doesn't _want_ +0 and -0 to act differently in almost any way. The only good rationale I've seen for why it makes the distinction at all is in Kahan's paper Branch Cuts for Complex Elementary Functions, or Much Ado

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-23 Thread Ivan Van Laningham
Hi All-- Tim Peters wrote: Fortran is so eager to allow optimizations that failure due to numeric differences in conformance tests rarely withstood challenge. +1 QOTW Metta, Ivan -- Ivan Van Laningham God N Locomotive Works

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-23 Thread Steven D'Aprano
Tim Peters wrote: [Steven D'Aprano] It isn't necessary to look at complex numbers to see the difference between positive and negative zero. Just look at a graph of y=1/x. In particular, look at the behaviour of the graph around x=0. Now tell me that the sign of zero doesn't make a difference.

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-23 Thread Robert Kern
Tim Peters wrote: OK, I looked, and it made no difference to me. Really. If I had an infinitely tall monitor, maybe I could see a difference, but I don't -- the sign of 0 on the nose makes no difference to the behavior of 1/x for any x other than 0. On my finite monitor, I see it looks

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Grant Edwards
On 2005-06-22, Scott David Daniels [EMAIL PROTECTED] wrote: I finally figured out why one of my apps sometimes fails under Win32 when it always works fine under Linux: Under Win32, the pickle module only works with a subset of floating point values. In particular the if you try to dump/load

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Scott David Daniels
Grant Edwards wrote: On 2005-06-22, Scott David Daniels [EMAIL PROTECTED] wrote: ...Under Win32, the pickle module only works with a subset of floating point values. In particular ... infinity or nan ... There is no completely portable way to do this. Python deals with all sorts of problems

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Grant Edwards
On 2005-06-22, Scott David Daniels [EMAIL PROTECTED] wrote: Fixing it is really quite trivial. It takes less than a dozen lines of code. Just catch the exception and handle it. Since you know it is quite trivial, and I don't, why not submit a patch resolving this issue. Be sure to include

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Scott David Daniels
Grant Edwards wrote: I'm working on it. I should have said it's trivial if you have access to the platforms to be supported. I've tested a fix that supports pickle streams generated under Win32 and glibc. That's using the native string representation of a NaN or Inf. Several issues: (1) The

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Terry Reedy
Grant Edwards [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I'm working on it. I should have said it's trivial if you have access to the platforms to be supported. I've tested a fix that supports pickle streams generated under Win32 and glibc. That's using the native string

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Grant Edwards
On 2005-06-22, Scott David Daniels [EMAIL PROTECTED] wrote: I'm working on it. I should have said it's trivial if you have access to the platforms to be supported. I've tested a fix that supports pickle streams generated under Win32 and glibc. That's using the native string representation

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Terry Reedy
Grant Edwards [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] The bit patterns are defined by the IEEE 754 standard. If there are Python-hosting platoforms that don't use IEEE 754 as the floating point representation, then that can be dealt with. Python has _tons_ of

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Scott David Daniels
Grant Edwards wrote: On 2005-06-22, Scott David Daniels [EMAIL PROTECTED] wrote: Several issues: (1) The number of distinct NaNs varies among platforms. According to the IEEE standard, there are exactly two: signalling and quiet, and on platforms that don't impliment floating point

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Paul Rubin
Scott David Daniels [EMAIL PROTECTED] writes: Negative 0 isn't a NaN, it's just negative 0. Right, but it is hard to construct in standard C. Huh? It's just a hex constant. -- http://mail.python.org/mailman/listinfo/python-list

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Scott David Daniels
Paul Rubin wrote: Scott David Daniels [EMAIL PROTECTED] writes: Negative 0 isn't a NaN, it's just negative 0. Right, but it is hard to construct in standard C. Huh? It's just a hex constant. Well, -0.0 doesn't work, and (double)0x8000 doesn't work, and I think you have to use

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Tim Peters
[with the start of US summer comes the start of 754 ranting season] [Grant Edwards] Negative 0 isn't a NaN, it's just negative 0. [Scott David Daniels] Right, but it is hard to construct in standard C. [Paul Rubin] Huh? It's just a hex constant. [Scott David Daniels] Well, -0.0 doesn't

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Paul Rubin
Scott David Daniels [EMAIL PROTECTED] writes: Negative 0 isn't a NaN, it's just negative 0. Right, but it is hard to construct in standard C. Huh? It's just a hex constant. Well, -0.0 doesn't work, and (double)0x8000 doesn't work, and I think you have to use quirks of a compiler

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Grant Edwards
On 2005-06-22, Scott David Daniels [EMAIL PROTECTED] wrote: Grant Edwards wrote: On 2005-06-22, Scott David Daniels [EMAIL PROTECTED] wrote: Several issues: (1) The number of distinct NaNs varies among platforms. According to the IEEE standard, there are exactly two: signalling and

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Grant Edwards
On 2005-06-22, Paul Rubin http wrote: Negative 0 isn't a NaN, it's just negative 0. Right, but it is hard to construct in standard C. Huh? It's just a hex constant. Yup. There are two ways to construct a NaN. One is to do something like (1e300*1e300)/(1e300*1e300) and hope for the best.

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Grant Edwards
On 2005-06-23, Paul Rubin http wrote: Scott David Daniels [EMAIL PROTECTED] writes: Negative 0 isn't a NaN, it's just negative 0. Right, but it is hard to construct in standard C. Huh? It's just a hex constant. Well, -0.0 doesn't work, and (double)0x8000 doesn't work, and I think

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Grant Edwards
On 2005-06-23, Tim Peters [EMAIL PROTECTED] wrote: C89 doesn't define the result of that, but most C compilers these days will create a negative 0. and (double)0x8000 doesn't work, I think you meant something like float f; *((uint32_t*)d) = 0x; And I don't know how to test

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Grant Edwards
On 2005-06-23, Grant Edwards [EMAIL PROTECTED] wrote: On 2005-06-23, Tim Peters [EMAIL PROTECTED] wrote: C89 doesn't define the result of that, but most C compilers these days will create a negative 0. and (double)0x8000 doesn't work, I think you meant something like float f;

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Ivan Van Laningham
Hi All-- Tim Peters wrote: Across platforms with a 754-conforming libm, the most portable way is via using atan2(!): pz = 0.0 mz = -pz from math import atan2 atan2(pz, pz) 0.0 atan2(mz, mz) -3.1415926535897931 Never fails. Tim, you gave me the best laugh of the day. Metta,

pickle broken: can't handle NaN or Infinity under win32

2005-06-21 Thread Grant Edwards
I finally figured out why one of my apps sometimes fails under Win32 when it always works fine under Linux: Under Win32, the pickle module only works with a subset of floating point values. In particular the if you try to dump/load an infinity or nan value, the load operation chokes: Under

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-21 Thread Grant Edwards
On 2005-06-21, Grant Edwards [EMAIL PROTECTED] wrote: I finally figured out why one of my apps sometimes fails under Win32 when it always works fine under Linux [...] Oh, I forgot, here's pickletest.py: #!/usr/bin/python import pickle f1 = (1e300*1e300) f2 = f1/f1 o = (f1,f2) s =