Paddy [EMAIL PROTECTED] wrote
Hey, I'm still learnin'. Sweet!
contrary to popular belief, the answer to life,
the universe, happiness and everything is
not 42, but the above.
- Hendrik
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] (Alex Martelli) writes:
This is not trivial to fix cleanly...:-(. compiler_add_o would have
to test is the object I'm storing -0.0 (I don't even know how to
do that in portable C...) and then do some kludge -- e.g. use as the
key into the dict (-0.0, 0) instead of (-0.0,
I get the following behaviour on Python 2.5 (OS X 10.4.8 on PowerPC,
in case it's relevant.)
x, y = 0.0, -0.0
x, y
(0.0, 0.0)
x, y = -0.0, 0.0
x, y
(-0.0, -0.0)
I would have expected y to be -0.0 in the first case, and 0.0 in the
second. Should the above be considered a bug, or is Python
On Mar 11, 9:31 am, Mark Dickinson [EMAIL PROTECTED] wrote:
I get the following behaviour on Python 2.5 (OS X 10.4.8 on PowerPC,
in case it's relevant.)
x, y = 0.0, -0.0
x, y
(0.0, 0.0)
x, y = -0.0, 0.0
x, y
(-0.0, -0.0)
I would have expected y to be -0.0 in the first case, and 0.0
On Sunday 11 March 2007 10:31, Mark Dickinson
wrote:
I get the following behaviour on Python 2.5 (OS
X 10.4.8 on PowerPC, in case it's relevant.)
x, y = 0.0, -0.0
x, y
(0.0, 0.0)
x, y = -0.0, 0.0
x, y
(-0.0, -0.0)
I would have expected y to be -0.0 in the first
case, and 0.0 in
Dan Bishop [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
| On Mar 11, 9:31 am, Mark Dickinson [EMAIL PROTECTED] wrote:
| I get the following behaviour on Python 2.5 (OS X 10.4.8 on PowerPC,
| in case it's relevant.)
|
| x, y = 0.0, -0.0
| x, y
| (0.0, 0.0)
| x, y = -0.0,
On Mar 11, 12:13 pm, Terry Reedy [EMAIL PROTECTED] wrote:
Dan Bishop [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
| On Mar 11, 9:31 am, Mark Dickinson [EMAIL PROTECTED] wrote:
| I get the following behaviour on Python 2.5 (OS X 10.4.8 on PowerPC,
| in case it's relevant.)
|
Mark Dickinson [EMAIL PROTECTED] wrote:
I guess what's happening is that there's some optimization that avoids
creating two separate float objects for a float literal that appears
twice, and that optimization doesn't see the difference between 0. and
-0.
Don't guess. Test.
def f():
Mark Dickinson [EMAIL PROTECTED] wrote:
I get the following behaviour on Python 2.5 (OS X 10.4.8 on PowerPC,
in case it's relevant.)
x, y = 0.0, -0.0
x, y
(0.0, 0.0)
x, y = -0.0, 0.0
x, y
(-0.0, -0.0)
I would have expected y to be -0.0 in the first case, and 0.0 in the
second.
On Mar 11, 1:21 pm, Duncan Booth [EMAIL PROTECTED] wrote:
Tim Peters wrote inhttp://blog.gmane.org/gmane.comp.python.devel/day=20050409:
All Python behavior in the presence of a NaN, infinity, or signed zero
is a platform-dependent accident. This is because C89 has no such
concepts, and
Duncan Booth [EMAIL PROTECTED] wrote:
Mark Dickinson [EMAIL PROTECTED] wrote:
I guess what's happening is that there's some optimization that avoids
creating two separate float objects for a float literal that appears
twice, and that optimization doesn't see the difference between 0. and
On Mar 11, 1:26 pm, [EMAIL PROTECTED] (Alex Martelli) wrote:
[Long analysis of probable cause of the problem]
Thank you for this. I was suspecting something along these lines,
but I don't yet know my way around the source well enough to figure
out where the problem was coming from.
In the
#
Interesting. So on Windows there's probably no
hope of what I want to do working.
But on a platform where the C library does the
right thing with signed zeros, this
behaviour is still a little surprising. I
guess what's happening is that there's
some optimization that avoids
Mark Dickinson [EMAIL PROTECTED] wrote:
On Mar 11, 1:26 pm, [EMAIL PROTECTED] (Alex Martelli) wrote:
[Long analysis of probable cause of the problem]
Thank you for this. I was suspecting something along these lines,
but I don't yet know my way around the source well enough to figure
out
Alex Martelli [EMAIL PROTECTED] wrote:
...
Yup: the workaround seems to be as simple as replacing all occurrences
of -0.0 with -(0.0). I'm embarrassed that I didn't figure this out
sooner.
x, y = -(0.0), 0.0
x, y
(-0.0, 0.0)
Glad it works for you, but it's the kind of
Alex Martelli wrote:
Alas, here is the problem...: 0.0 and -0.0 are NOT separate as dict
keys! They are == to each other. So are 0, 0L, and 0+j0, but the
compiler smartly distinguishes these cases by using (obj, type) as the
key (the *types* are distinguished, even though the *values*) are;
En Sun, 11 Mar 2007 15:26:01 -0300, Alex Martelli [EMAIL PROTECTED] escribió:
Or maybe we should give up ever storing -0.0 in the tables
of constant and ALWAYS have 0.0, unary-minus wherever it appears (that
would presumably require working on the AST-to-bytecode visitors that
currently work
On Mar 11, 2:59 pm, [EMAIL PROTECTED] (Alex Martelli) wrote:
[...]
OTOH, Python 2.4 works just fine...:
Python 2.4.3 (#1, Apr 7 2006, 10:54:33)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type help, copyright, credits or license for more information.
0.0,-0.0
(0.0, -0.0)
[attribution lost]
...
Yup: the workaround seems to be as simple as replacing all
occurrences
of -0.0 with -(0.0). I'm embarrassed that I didn't figure this out
sooner.
x, y = -(0.0), 0.0
x, y
(-0.0, 0.0)
[Alex Martelli]
Glad it works for you, but it's the kind of workaround that
Tim Peters [EMAIL PROTECTED] writes:
2.5 introduced a new front end and more ambitious constant-folding, and
I expect the bug showed up again due to one of those.
I hope it does get fixed. Not having referential transparency in a
basic math function like atan2 is pretty disturbing in a modern
Dennis Lee Bieber [EMAIL PROTECTED] writes:
Pardon? What is the right thing with signed zeros... In the last
30 years I've been on machines that normalize floating zero into a true
zero (all bits are zero: mantissa, exponent, and sign). This is the
first time I've even seen a variable
On Mar 11, 5:15 pm, Tim Peters [EMAIL PROTECTED] wrote:
It's a bug that keeps resurfacing, probably because there's no
portable
way to test that it stays fixed :-( (it's not an accident that the OP
relied on atan2 to distinguish +0.0 from -0.0! they act the same in
/almost/ all contexts).
Mark Dickinson [EMAIL PROTECTED] writes:
By the way, I don't suppose that anybody would be interested in
a rewritten cmath for Python 2.6? It wouldn't be hard for me to
rewrite what I already have in C, and add suitable documentation
and tests.
I can't speak for the developers but my
On Mar 11, 9:28 pm, Paul Rubin http://[EMAIL PROTECTED] wrote:
Dennis Lee Bieber [EMAIL PROTECTED] writes:
Pardon? What is the right thing with signed zeros... In the last
30 years I've been on machines that normalize floating zero into a true
zero (all bits are zero: mantissa,
Gabriel Genellina wrote:
(I cannot find peephole.c on the source distribution for Python 2.5, but
you menctioned it on a previous message, and the comment above refers to
the peephole optimizer... where is it?)
The peephole optimizer is in compile.c - the entry point is optimize_code
Paddy [EMAIL PROTECTED] writes:
Most machines these days use IEEE 754 which supports negative zero.
http://en.wikipedia.org/wiki/Negative_zero
Isn't negative zero mathematically the same as zero? Isn't -0 just an
artefact of the representation of floating point numbers? Shouldn't
f(0) ==
On Mar 11, 7:49 pm, Paddy [EMAIL PROTECTED] wrote:
Isn't negative zero mathematically the same as zero? Isn't -0 just an
artefact of the representation of floating point numbers? Shouldn't
f(0) == f(-0) for all functions f?
Read the original post again... The relevant part is:
I'm
Gabriel Genellina [EMAIL PROTECTED] wrote:
En Sun, 11 Mar 2007 15:26:01 -0300, Alex Martelli [EMAIL PROTECTED]
escribió:
Or maybe we should give up ever storing -0.0 in the tables
of constant and ALWAYS have 0.0, unary-minus wherever it appears (that
would presumably require working on
Alex Martelli [EMAIL PROTECTED] wrote:
...
Yep, it sure might, if I can make time to act on it:-).
...and I did -- patch 1678668 is right there, brand newm at
http://sourceforge.net/tracker/index.php .
I hope it also satisfies the timbot's very reasonable lament about the
bug resurfacing
Mark Dickinson [EMAIL PROTECTED] wrote:
On Mar 11, 2:59 pm, [EMAIL PROTECTED] (Alex Martelli) wrote:
[...]
OTOH, Python 2.4 works just fine...:
Python 2.4.3 (#1, Apr 7 2006, 10:54:33) [GCC 4.0.1 (Apple Computer,
Inc. build 5250)] on darwin Type help, copyright, credits or
license
Tim Peters [EMAIL PROTECTED] wrote:
...
It's a bug that keeps resurfacing, probably because there's no portable
way to test that it stays fixed :-( (it's not an accident that the OP
relied on atan2 to distinguish +0.0 from -0.0! they act the same in
Please take a look at my patch 1678668,
Paul Rubin http://[EMAIL PROTECTED] wrote:
(rejected) for Python to support exact rational arithmetic in addition
to floating point and exact integer arithmetic. Exact rationals in
Python (if implemented) should behave like mathematical rationals.
But Python floating point arithmetic should
[EMAIL PROTECTED] (Alex Martelli) writes:
Incidentally (and I know you know that, Paul, but others interested in
this thread might not) fast exact rational arithmetic (based on the LGPL
library named GMP) is supplied, among other functionality, by module
gmpy, currently found at
Jorge Godoy [EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] (Alex Martelli) writes:
Incidentally (and I know you know that, Paul, but others interested in
this thread might not) fast exact rational arithmetic (based on the LGPL
library named GMP) is supplied, among other functionality, by
[EMAIL PROTECTED] (Alex Martelli) writes:
I'm not familiar with setuptools, what exactly is it looking for?
If it's looking for stuff to download it should start at
http://code.google.com/p/gmpy/downloads/list
(but what does it want -- the sources' zipfile, or some binary, and in
what
On Mar 11, 9:56 pm, [EMAIL PROTECTED] (Alex Martelli) wrote:
That bug isn't formally closed yet, and the discussion's going on, we'll
see. Meanwhile can you try my patch 1678668 just to double check it
does fix everything? (It's agains the current HEAD of Python's svn).
It does, and all
On Mar 11, 10:49 pm, Paddy [EMAIL PROTECTED] wrote:
On Mar 11, 9:28 pm, Paul Rubin http://[EMAIL PROTECTED] wrote:
Dennis Lee Bieber [EMAIL PROTECTED] writes:
Pardon? What is the right thing with signed zeros... In the last
30 years I've been on machines that normalize floating zero
37 matches
Mail list logo