Re: Timing problem?

2019-03-21 Thread Chris Angelico
On Fri, Mar 22, 2019 at 1:01 AM Steve wrote: > > I believe I can see what is happening here but maybe someone can explain > least I run into this again. > > Situation 1: I am using "ws.MessageBeep(1)" to generate a tone through the > speakers. I wanted two tones to separate it from other tones t

Re: timing issue: shutil.rmtree and os.makedirs

2013-07-30 Thread Göktuğ Kayaalp
On Jul 30, 2013 3:29 PM, "Chris Angelico" wrote: > > On Tue, Jul 30, 2013 at 2:10 PM, Tim wrote: > > hmm, now that you mention it, this is executing on a remote box with access to the same file system my local calling program is on. That is, there is a local call to an intermediate script that co

Re: timing issue: shutil.rmtree and os.makedirs

2013-07-30 Thread Chris Angelico
On Tue, Jul 30, 2013 at 4:37 PM, Tim wrote: > Argg, this isn't the first time I've had troubles with the file system. This > is FreeBSD and NFS. I will code up a progressive delay as you mentioned (with > Steve's correction). I've used several different networked file systems, including NetBIOS

Re: timing issue: shutil.rmtree and os.makedirs

2013-07-30 Thread Tim
On Tuesday, July 30, 2013 9:27:10 AM UTC-4, Chris Angelico wrote: > On Tue, Jul 30, 2013 at 2:10 PM, Tim wrote: > > hmm, now that you mention it, this is executing on a remote box with access > > to the same file system my local calling program is on. That is, there is a > > local call to an inte

Re: timing issue: shutil.rmtree and os.makedirs

2013-07-30 Thread Chris Angelico
On Tue, Jul 30, 2013 at 3:07 PM, Steven D'Aprano wrote: > On Tue, 30 Jul 2013 14:27:10 +0100, Chris Angelico wrote: > >> for delay in 100,300,600,1000,3000,5000,1: >> if not os.path.exists(directory): break >> sleep(delay) >> >> That'll sleep a maximum of 20 seconds, tune as required. > >

Re: timing issue: shutil.rmtree and os.makedirs

2013-07-30 Thread Steven D'Aprano
On Tue, 30 Jul 2013 14:27:10 +0100, Chris Angelico wrote: > for delay in 100,300,600,1000,3000,5000,1: > if not os.path.exists(directory): break > sleep(delay) > > That'll sleep a maximum of 20 seconds, tune as required. Actually, that will sleep a maximum of 5.55 hours, and a minimum of

Re: timing issue: shutil.rmtree and os.makedirs

2013-07-30 Thread Chris Angelico
On Tue, Jul 30, 2013 at 2:10 PM, Tim wrote: > hmm, now that you mention it, this is executing on a remote box with access > to the same file system my local calling program is on. That is, there is a > local call to an intermediate script that connects to a socket on the remote > where the abov

Re: timing issue: shutil.rmtree and os.makedirs

2013-07-30 Thread Tim
On Monday, July 29, 2013 7:52:36 PM UTC-4, Chris Angelico wrote: > On Mon, Jul 29, 2013 at 8:16 PM, Tim wrote: > > My intent is to pass it a directory name or path and if it exists, use > > shutil.rmtree to remove whatever is there (if it isn't a directory, try to > > unlink it); then use os.make

Re: timing issue: shutil.rmtree and os.makedirs

2013-07-29 Thread Chris Angelico
On Mon, Jul 29, 2013 at 8:16 PM, Tim wrote: > My intent is to pass it a directory name or path and if it exists, use > shutil.rmtree to remove whatever is there (if it isn't a directory, try to > unlink it); then use os.makedirs to create a new directory or path: > > def make_clean_dir(directory

Re: Timing of string membership (was Re: hex dump w/ or w/out utf-8 chars)

2013-07-14 Thread Chris Angelico
On Mon, Jul 15, 2013 at 2:18 PM, Terry Reedy wrote: > On 7/14/2013 10:56 AM, Chris Angelico wrote: > As issue about finding stings in strings was opened last September and, as > reported on this list, fixes were applied about last March. As I remember, > some but not all of the optimizations were

Re: Timing of string membership (was Re: hex dump w/ or w/out utf-8 chars)

2013-07-14 Thread Terry Reedy
On 7/14/2013 10:56 AM, Chris Angelico wrote: On Sun, Jul 14, 2013 at 11:44 PM, wrote: timeit.repeat("a = 'hundred'; 'x' in a") [0.11785943134991479, 0.09850454944486256, 0.09761604599423179] timeit.repeat("a = 'hundreœ'; 'x' in a") [0.23955250303158593, 0.2195812612416752, 0.2213389699740

Re: timing

2010-07-19 Thread Alex A.
You could use pycallgraph module Regards, Alex Abushkevich -- http://mail.python.org/mailman/listinfo/python-list

Re: timing

2010-07-16 Thread Jia Hu
Thank you, it is so straightforward. On Fri, Jul 16, 2010 at 9:58 PM, Chris Rebert wrote: > On Fri, Jul 16, 2010 at 5:52 PM, Jia Hu wrote: > > Hello: > > > > If I want to calculate the runtime of a section of a program. How can I > do > > it? > > Taking you extremely literally: > from time impo

Re: timing

2010-07-16 Thread Chris Rebert
On Fri, Jul 16, 2010 at 5:52 PM, Jia Hu wrote: > Hello: > > If I want to calculate the runtime of a section of a program. How can I do > it? Taking you extremely literally: from time import time start = time() run_section_here() end = time() runtime = end-start Assuming you're doing this in orde

Re: timing puzzle

2007-11-16 Thread Neil Cerutti
On 2007-11-16, Robin Becker <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: > ... > > > see why. >> >> You are no longer making m copies of active_nodes. > > my profiling indicated that the main problem was the removes. Yeah, I should've added, "for one thing." I'm glad Chris correctly poi

Re: timing puzzle

2007-11-16 Thread Robin Becker
Neil Cerutti wrote: ... see why. > > You are no longer making m copies of active_nodes. my profiling indicated that the main problem was the removes. > > > When you have to make many deletions from the middle of a > sequence, you would normally choose a linked list. Python doe

Re: timing puzzle

2007-11-16 Thread Robin Becker
Chris Mellon wrote: > > remove() does a linear search to find the item to remove, so it's O(n) > + the actual deletion. Append() is amortized O(1) (overcommit). If you > delete by index instead: > for idx, node in active_nodes: > if cond: > del active_nodes[idx] > > that's what I

Re: timing puzzle

2007-11-16 Thread Neil Cerutti
On 2007-11-16, Neil Cerutti <[EMAIL PROTECTED]> wrote: > Instead, filter your list. It looks like you can't use filter > directly, so just do it manually. > >for i in xrange(m): >... >saved_nodes = [] >for A in active_nodes[:]: I meant to remove the slice. That line

Re: timing puzzle

2007-11-16 Thread Neil Cerutti
On 2007-11-16, Robin Becker <[EMAIL PROTECTED]> wrote: > I'm trying to get my head round a timing puzzle I find whilst > optimizing A Kuchling's version of the Knuth line splitting > algorithm from the oedipus project. The puzzle is as follows in > highly abstract form (here active_nodes is a list

Re: timing puzzle

2007-11-16 Thread Chris Mellon
On Nov 16, 2007 12:42 PM, Robin Becker <[EMAIL PROTECTED]> wrote: > I'm trying to get my head round a timing puzzle I find whilst optimizing A > Kuchling's version of the Knuth line splitting algorithm from the oedipus > project. The puzzle is as follows in highly abstract form (here > active_nod

Re: Timing a python program run

2007-07-08 Thread i3dmaster
simplest way is just put a timer on start and another on the end, then calc the elapse. You can also take a look timeit module too which provides similar but more powerful functions... -Jim On Jul 7, 2007, at 12:21 PM, David wrote: > Hi, > > In matlab, I'd calculate the time for a script nam

Re: Timing a python program run

2007-07-07 Thread Jyotirmoy Bhattacharya
On Jul 8, 12:21 am, David <[EMAIL PROTECTED]> wrote: > Hi, > > In matlab, I'd calculate the time for a script named test.m to run > with: > > >> tic, run, toc > > Is there some way to do this in python on a mac os x from the terminal > window? Or whatever? The timeit module may be of use: http://d

Re: Timing a python program run

2007-07-07 Thread Lawrence Oluyede
David <[EMAIL PROTECTED]> wrote: > Is there some way to do this in python on a mac os x from the terminal > window? Or whatever? You can use: % time script.py from the command line of the terminal -- Lawrence, oluyede.org - neropercaso.it "It is difficult to get a man to understand something

Re: Timing a function object versus timeit

2006-11-03 Thread Steven D'Aprano
On Fri, 03 Nov 2006 18:02:37 -0800, Carl Banks wrote: import timeit timeit.Timer("foo(1)","from __main__ import foo") > 1.1497418880462646 Well, that was scarily simple. Thank you. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list

Re: Timing a function object versus timeit

2006-11-03 Thread Carl Banks
Steven D'Aprano wrote: > The timeit module is ideal for measuring small code snippets; I want to > measure large function objects. > > Because the timeit module takes the code snippet argument as a string, it > is quite handy to use from the command line, but it is less convenient for > timing lar

Re: TIming

2006-05-31 Thread Tim Roberts
WIdgeteye <[EMAIL PROTECTED]> wrote: >On Tue, 30 May 2006 16:15:44 +1000, John McMonagle wrote: > >> Tim Roberts is right. As you are on linux, I suggest you investigate the >> at command - very user friendly and not at all complicated. > >I have been using Slackware for over 10 years I know all

Re: TIming

2006-05-30 Thread John Bokma
WIdgeteye <[EMAIL PROTECTED]> wrote: > BTW in the time it took me NOT to get an answer for my question in > this so called Python NG, I figured it out for myself. Maybe you want to post the solution in order to help others with similar problems in the future? -- John

Re: TIming

2006-05-30 Thread John Machin
On 31/05/2006 5:50 AM, WIdgeteye wrote: > > This PYTHON NG blows to high heaven. Whats worse, the answers I got were > most likely from people who know SQUAT about Python scripting. That's why > they gave me such lame [expletive deleted] answers. > > Idiots. Kindly refer back to your post of

Re: TIming

2006-05-30 Thread jack2004fb
You can try this EnergyKey http://www30.webSamba.com/SmartStudio This may be help you. Now I always use EnergyKey, it helps me so much in my work. -- http://mail.python.org/mailman/listinfo/python-list

Re: TIming

2006-05-30 Thread Scott David Daniels
WIdgeteye wrote: > Thank you very much for your participation. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: TIming

2006-05-30 Thread Jean-Paul Calderone
On Tue, 30 May 2006 14:50:38 -0500, WIdgeteye <[EMAIL PROTECTED]> wrote: > > [snip] > >This PYTHON NG blows to high heaven. Whats worse, the answers I got were >most likely from people who know SQUAT about Python scripting. That's why >they gave me such lame fucking answers. > >Idiots. While that

Re: TIming

2006-05-30 Thread WIdgeteye
On Tue, 30 May 2006 16:15:44 +1000, John McMonagle wrote: > Tue, 2006-05-30 at 00:23 -0500, WIdgeteye wrote: >> On Tue, 30 May 2006 04:34:03 +, Tim Roberts wrote: >> >> > WIdgeteye <[EMAIL PROTECTED]> wrote: >> >>HI, >> >>I am trying to write a little program that will run a program on >> >>s

Re: TIming

2006-05-30 Thread bruno at modulix
WIdgeteye wrote: > HI, > I am trying to write a little program that will run a program on > scedule. There are usually existing programs to do so on most platforms (cron on *n*x, the Windows scheduler, etc). -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('

Re: TIming

2006-05-29 Thread John McMonagle
Tue, 2006-05-30 at 00:23 -0500, WIdgeteye wrote: > On Tue, 30 May 2006 04:34:03 +, Tim Roberts wrote: > > > WIdgeteye <[EMAIL PROTECTED]> wrote: > >>HI, > >>I am trying to write a little program that will run a program on scedule. > >>I am having trouble understanding the datetime, time, sched

Re: TIming

2006-05-29 Thread WIdgeteye
On Tue, 30 May 2006 04:34:03 +, Tim Roberts wrote: > WIdgeteye <[EMAIL PROTECTED]> wrote: >>HI, >>I am trying to write a little program that will run a program on scedule. >>I am having trouble understanding the datetime, time, sched modules. What >>I would like is something like this: >> >>If

Re: TIming

2006-05-29 Thread Tim Roberts
WIdgeteye <[EMAIL PROTECTED]> wrote: >HI, >I am trying to write a little program that will run a program on >scedule. I am having trouble understanding the datetime, time, sched >modules. What I would like is something like this: > >If date&time = 06-13-2006:18:00:00 >Then run this program > >I am

Re: Timing out arbitrary functions

2005-12-28 Thread antti kervinen
AOP would be a quite elegant way set timeouts for functions, in my opinion. The nice thing in it is that, in principle, you can write a single timeout advice code and then wrap it over any function you want to timeout. I wrote timeout_advice.py to demonstrate this a couple of years ago (see http:/

Re: Timing out arbitrary functions

2005-12-24 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > > Is something stopping you from using sigalarm? > > Pure ignorance of its existence. > Thanks, I'll check it out. Two things to keep in mind: - You can have only ONE alarm pending for the whole process. If different things in the program need tim

Re: Timing out arbitrary functions

2005-12-24 Thread Steven D'Aprano
On Sat, 24 Dec 2005 04:47:34 -0800, Paul Rubin wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: >> How do others handle something like this? What should I be looking for? >> I'm after a lightweight solution, if any such thing exists. > > Is something stopping you from using sigalarm? Pure ig

Re: Timing out arbitrary functions

2005-12-24 Thread David Wahler
Steven D'Aprano wrote: > I have a problem and I don't know where to start looking for a solution. > > I have a class that needs to call an arbitrary function and wait for a > result. The function, being completely arbitrary and not under my control, > may be very time consuming and possibly may not

Re: Timing out arbitrary functions

2005-12-24 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > How do others handle something like this? What should I be looking for? > I'm after a lightweight solution, if any such thing exists. Is something stopping you from using sigalarm? -- http://mail.python.org/mailman/listinfo/python-list