Re: Signed zeros: is this a bug?

2007-03-11 Thread Mark Dickinson
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 me

Re: Signed zeros: is this a bug?

2007-03-11 Thread Mark Dickinson
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 > > concep

Re: Signed zeros: is this a bug?

2007-03-11 Thread Mark Dickinson
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 follow

Signed zeros: is this a bug?

2007-03-11 Thread Mark Dickinson
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 i

cmath, __float__ and __complex__

2007-02-15 Thread Mark Dickinson
I was a little surprised by the following behaviour: Python 2.5 (r25, Oct 30 2006, 20:50:32) [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from cmath import sqrt >>> class NumericType1(object): ... def __float

Re: Conflicting needs for __init__ method

2007-01-16 Thread Mark Dickinson
On Jan 16, 10:25 am, "Mark Dickinson" <[EMAIL PROTECTED]> wrote: > that is, I was working from the following two assumptions: > > (1) *Every* time a Rational is created, __init__ must eventually be > called, and > (2) The user of the class expects to call Rational(

Re: Conflicting needs for __init__ method

2007-01-16 Thread Mark Dickinson
On Jan 15, 4:54 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] writes: > > Suppose you're writing a class "Rational" for rational numbers. The > > __init__ function of such a class has two quite different roles to > > play. > That should be your first clue to question whether you're

Re: Conflicting needs for __init__ method

2007-01-15 Thread Mark Dickinson
On Jan 14, 10:43 pm, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Sun, 14 Jan 2007 15:32:35 -0800, dickinsm wrote: > > (You could include the normalization in __init__, but that's wasteful > Is it really? Have you measured it or are you guessing? Is it more or less > wasteful than any other so

Re: Conflicting needs for __init__ method

2007-01-15 Thread Mark Dickinson
On Jan 14, 7:49 pm, "Ziga Seilnacht" <[EMAIL PROTECTED]> wrote: > Mark wrote:[a lot of valid, but long concerns about types that return > an object of their own type from some of their methods] > > I think that the best solution is to use an alternative constructor > in your arithmetic methods. Th

python coding contest

2005-12-30 Thread Mark Dickinson
Here's a variant of André's brilliant idea that's 119 characters long, and fully printable: j=''.join;seven_seg=lambda z:j(j(' _ | |_ _|_|' [ord('^r|=Zm.:v\r'[int(a)])%u*2:][:3]for a in z) +"\n"for u in(3,7,8)) Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Mark Dickinson
In article <[EMAIL PROTECTED]>, Bill Mill <[EMAIL PROTECTED]> wrote: > I'm also pretty sure I've caught a bug in his code, though I'm not > sure how it works exactly. I replaced the 'min' built-in with my own > min, and he's going to get nondeterministic results from this line: > >mm =

Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Mark Dickinson
In article <[EMAIL PROTECTED]>, Stelios Xanthakis <[EMAIL PROTECTED]> wrote: > In the sudoku solver, there is a min (number, object) which is > probably what's affected by the extistance of the dummy variable. > Now, in sudoku puzzles some times the algorithm has to suppose > that in a box the r

Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Mark Dickinson
In article <[EMAIL PROTECTED]>, Bill Mill <[EMAIL PROTECTED]> wrote: > One of my own: what in the world made you think "maybe I'll add 29 > dummy global variables to speed things up?" You mean this isn't a well-known optimization technique? :) I was refactoring the code, and after making a part

Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Mark Dickinson
I have a simple 192-line Python script that begins with the line: dummy0 = 47 The script runs in less than 2.5 seconds. The variable dummy0 is never referenced again, directly or indirectly, by the rest of the script. Here's the surprise: if I remove or comment out this first line, the script t

<    1   2   3   4   5