Re: [Tutor] Efficiency and speed

2010-03-22 Thread Alan Gauld
"James Reynolds" wrote On that end, I'm almost done readying "beginning Python: From Novice to Professional" Can anyone recommend anything else for me to read after that? I'm not familiar with that book but I'd say consider what area of programming you are interested in and get a specialist

Re: [Tutor] Efficiency and speed

2010-03-21 Thread James Reynolds
On Sat, Mar 20, 2010 at 1:17 PM, Steven D'Aprano wrote: > On Sat, 20 Mar 2010 05:47:45 am James Reynolds wrote: > > > This is a monte-carlo simulation. > > > > The simulation measures the expiration of something and those > > somethings fall into bins that are not evenly dispersed. These bins > >

Re: [Tutor] Efficiency and speed

2010-03-20 Thread Steven D'Aprano
On Sat, 20 Mar 2010 05:47:45 am James Reynolds wrote: > This is a monte-carlo simulation. > > The simulation measures the expiration of something and those > somethings fall into bins that are not evenly dispersed. These bins > are stored in the nx list mentioned previously. > > So let's say you h

Re: [Tutor] Efficiency and speed

2010-03-20 Thread Steven D'Aprano
On Sat, 20 Mar 2010 03:41:11 am James Reynolds wrote: > I've still been working towards learning the language, albeit slowly > and I've been working on a project that is somewhat intense on the > numerical calculation end of things. > > Running 10,000 trials takes about 1.5 seconds and running 100

Re: [Tutor] Efficiency and speed

2010-03-20 Thread Dave Angel
(Please don't top-post. It ruins the context for anyone else trying to follow it. Post your remarks at the end, or immediately after whatever you're commenting on.) James Reynolds wrote: Here's another idea I had. I thought this would be slower than then the previous algorithm because it has

Re: [Tutor] Efficiency and speed

2010-03-19 Thread Stefan Behnel
James Reynolds, 19.03.2010 21:17: Here's another idea I had. I thought this would be slower than then the previous algorithm because it has another for loop and another while loop. I read that the overhead of such loops is high, so I have been trying to avoid using them where possible. Prematur

Re: [Tutor] Efficiency and speed

2010-03-19 Thread Alan Gauld
"James Reynolds" wrote Here's another idea I had. I thought this would be slower than then the previous algorithm because it has another for loop and another while loop. I read that the overhead of such loops is high, so I have been trying to avoid using them where possible. Thats often t

Re: [Tutor] Efficiency and speed

2010-03-19 Thread Luke Paireepinart
On Fri, Mar 19, 2010 at 3:17 PM, James Reynolds wrote: > Here's another idea I had. I thought this would be slower than then the > previous algorithm because it has another for loop and another while loop. I > read that the overhead of such loops is high, so I have been trying to avoid > using th

Re: [Tutor] Efficiency and speed

2010-03-19 Thread James Reynolds
Here's another idea I had. I thought this would be slower than then the previous algorithm because it has another for loop and another while loop. I read that the overhead of such loops is high, so I have been trying to avoid using them where possible. def mcrange_gen(self, sample): nx

Re: [Tutor] Efficiency and speed

2010-03-19 Thread Alan Gauld
"James Reynolds" wrote I've made a few other optimizations today that I won't be able to test until I get home, but I was wondering if any of you could give some general pointers on how to make python run a little more quickly. Always, always, get the algorithm efficient before trying to mak

Re: [Tutor] Efficiency and speed

2010-03-19 Thread Emile van Sebille
On 3/19/2010 9:41 AM James Reynolds said... OK, so starting here: def mcrange_gen(self, sample): lensample = len(sample) nx2 = self.nx1 nx2_append = nx2.append nx2_sort = nx2.sort nx2_reverse = nx2.reverse nx2_index = nx2.index nx2_remove = nx2.remove for s in ra

Re: [Tutor] Efficiency and speed

2010-03-19 Thread James Reynolds
Well, I'm always out to impress! This is a monte-carlo simulation. The simulation measures the expiration of something and those somethings fall into bins that are not evenly dispersed. These bins are stored in the nx list mentioned previously. So let's say you have the bins, a, b,c,d,e,f and yo

Re: [Tutor] Efficiency and speed

2010-03-19 Thread Stefan Behnel
James Reynolds, 19.03.2010 17:41: I've still been working towards learning the language, albeit slowly and I've been working on a project that is somewhat intense on the numerical calculation end of things. Running 10,000 trials takes about 1.5 seconds and running 100,000 trials takes 11 seconds

[Tutor] Efficiency and speed

2010-03-19 Thread James Reynolds
Hello all: I've still been working towards learning the language, albeit slowly and I've been working on a project that is somewhat intense on the numerical calculation end of things. Running 10,000 trials takes about 1.5 seconds and running 100,000 trials takes 11 seconds. Running a million tria