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

2005-08-26 Thread Raymond Hettinger
[Raymond Hettinger] > > With respect to > > distribution, it should be noted that string hash values are decidely > > non-random and your variable names likely congested consecutive spaces > > in a nearly full table (resulting in seven times as many search probes > > to find a global value). > > >

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

2005-08-26 Thread Benjamin Niemann
Raymond Hettinger wrote: > > Mark Dickinson wrote: >> 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. >> >> Her

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

2005-08-25 Thread Claudio Grondi
> I've learnt my lesson :) Thank you for your help, and apologies > for wasting other people's time with this as well as my own! I've learnt my lesson reading through this thread, too. I am glad to be given the chance of wasting my time with it and very happy and thankful, that you posted your

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

2005-08-25 Thread MrJean1
Two observations: 1 - The difference in run time with and without the dummy* globals is due to a difference in the number of invokations of the search() function: 1,140 resp. 27,530 in my environment. To verify, just change the line def search(): to searches = 0 def search():

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

2005-08-25 Thread rafi
Stelios Xanthakis wrote: > Mark Dickinson wrote: > >> 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

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

2005-08-25 Thread Raymond Hettinger
Mark Dickinson wrote: > 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 comme

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 Bill Mill
On 8/25/05, Jack Diederich <[EMAIL PROTECTED]> wrote: > On Thu, Aug 25, 2005 at 09:23:09PM +0300, Stelios Xanthakis wrote: > > The explanation is this: hash > > and comparison of objects depends on the state of the memory > > allocator. A sample case is this: > > > > class A: pass > >

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

2005-08-25 Thread Jack Diederich
On Thu, Aug 25, 2005 at 09:23:09PM +0300, Stelios Xanthakis wrote: > The explanation is this: hash > and comparison of objects depends on the state of the memory > allocator. A sample case is this: > > class A: pass > dummy0=47 # comment this to get a different result for min >

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

2005-08-25 Thread Bill Mill
On 8/25/05, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Bill Mill wrote: > > > Unlikely; 2 people have confirmed these results already. > > > > I did find, though, that if I remove all print statements from the > > program, the dummy and non-dummy variable versions take indentical > > time. Can

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

2005-08-25 Thread Stelios Xanthakis
Mark Dickinson wrote: > 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 com

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

2005-08-25 Thread Bill Mill
On 8/25/05, Jack Diederich <[EMAIL PROTECTED]> wrote: > On Thu, Aug 25, 2005 at 01:35:04PM -0400, Bill Mill wrote: > > On 8/25/05, Erik Max Francis <[EMAIL PROTECTED]> wrote: > > > Mark Dickinson wrote: > > > > > > > Questions: > > > > > > > > (1) Can anyone else reproduce this behaviour, or is it

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

2005-08-25 Thread Jack Diederich
On Thu, Aug 25, 2005 at 01:55:48PM -0400, Bill Mill wrote: > Bill Mill wrote: > > > > Pentium M 1.8 GHz Windows 2k. Here's the top of the profile results > > for fast and slow on my machine (these won't look decent except in a > > fixed-width font): > > > > > > > Interestingly, the test.py:36 li

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

2005-08-25 Thread jay graves
Mark Dickinson wrote: > Questions: > (1) Can anyone else reproduce this behaviour, or is it just some quirk > of my setup? yes. I get 7 sec vs 1 sec on my laptop. > (2) Any possible explanations? Is there some optimization that kicks > in at a certain number of lines, or at a certain le

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

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

2005-08-25 Thread Jack Diederich
On Thu, Aug 25, 2005 at 01:35:04PM -0400, Bill Mill wrote: > On 8/25/05, Erik Max Francis <[EMAIL PROTECTED]> wrote: > > Mark Dickinson wrote: > > > > > Questions: > > > > > > (1) Can anyone else reproduce this behaviour, or is it just some quirk > > > of my setup? > > > (2) Any possible expla

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

2005-08-25 Thread Bill Mill
Bill Mill wrote: > > Pentium M 1.8 GHz Windows 2k. Here's the top of the profile results > for fast and slow on my machine (these won't look decent except in a > fixed-width font): > > > Interestingly, the test.py:36 line, which takes 45 seconds (!!) in the > slow version, does not appear at all

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

2005-08-25 Thread Erik Max Francis
Bill Mill wrote: > Unlikely; 2 people have confirmed these results already. > > I did find, though, that if I remove all print statements from the > program, the dummy and non-dummy variable versions take indentical > time. Can others reproduce this? Yes, it's obviously a real effect given the o

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

2005-08-25 Thread Bill Mill
On 8/25/05, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Mark Dickinson wrote: > > > Questions: > > > > (1) Can anyone else reproduce this behaviour, or is it just some quirk > > of my setup? > > (2) Any possible explanations? Is there some optimization that kicks > > in at a certain num

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

2005-08-25 Thread Bill Mill
On 8/25/05, Mark Dickinson <[EMAIL PROTECTED]> wrote: > 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

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

2005-08-25 Thread Erik Max Francis
Mark Dickinson wrote: > Questions: > > (1) Can anyone else reproduce this behaviour, or is it just some quirk > of my setup? > (2) Any possible explanations? Is there some optimization that kicks > in at a certain number of lines, or at a certain length of > bytecode? > (3) If (2), i

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

2005-08-25 Thread Jack Diederich
On Thu, Aug 25, 2005 at 04:44:24PM +, Mark Dickinson wrote: > 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. >

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