Re: [Tutor] Astonishing timing result

2008-06-27 Thread Dick Moores
At 04:28 AM 6/27/2008, Kent Johnson wrote: On Fri, Jun 27, 2008 at 6:48 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > Instead I've tried to find out if it's true what Alex Martelli writes on p. > 484 in the section, "Building up a string from pieces" in his _Python in a > Nutshell_, 2nd ed., whic

Re: [Tutor] Astonishing timing result

2008-06-27 Thread Kent Johnson
On Fri, Jun 27, 2008 at 6:48 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > Instead I've tried to find out if it's true what Alex Martelli writes on p. > 484 in the section, "Building up a string from pieces" in his _Python in a > Nutshell_, 2nd ed., which covers Python 2.4x. You might be intereste

Re: [Tutor] Astonishing timing result

2008-06-27 Thread Dick Moores
At 05:57 AM 6/26/2008, Kent Johnson wrote: On Thu, Jun 26, 2008 at 3:18 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > I thought I'd use this to compare the 2 ways of string concatenation. Ever > since I began to learn Python I've been told that only one of these is the > proper and efficient one t

Re: [Tutor] Astonishing timing result

2008-06-26 Thread Kent Johnson
On Thu, Jun 26, 2008 at 3:18 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > I thought I'd use this to compare the 2 ways of string concatenation. Ever > since I began to learn Python I've been told that only one of these is the > proper and efficient one to use, and especially so if the string to be

Re: [Tutor] Astonishing timing result

2008-06-26 Thread Dick Moores
At 05:52 PM 6/24/2008, Dick Moores wrote: At 05:35 PM 6/24/2008, Kent Johnson wrote: On Tue, Jun 24, 2008 at 5:20 PM, Dick Moores <[EMAIL PROTECTED]> wrote: > Basically, I'm not worried, just curious. Not about the small differences, > but why did the use of the standard    if __name__ == '__main

Re: [Tutor] Astonishing timing result

2008-06-25 Thread Marilyn Davis
On Tue, June 24, 2008 10:16 pm, Dick Moores wrote: > At 07:00 PM 6/24/2008, Marilyn Davis wrote: > > >> Has anyone ever timed the difference between using a function that was >> imported with: >> >> from my_module import MyFunction >> >> and: >> >> >> import my_module > > Here are 2 comparisons: <

Re: [Tutor] Astonishing timing result

2008-06-25 Thread Lie Ryan
On Wed, 2008-06-25 at 15:53 -0400, Kent Johnson wrote: > On Wed, Jun 25, 2008 at 2:06 PM, Lie Ryan <[EMAIL PROTECTED]> wrote: > > On Wed, 2008-06-25 at 12:56 -0400, Kent Johnson wrote: > >> On Wed, Jun 25, 2008 at 12:05 PM, Lie Ryan <[EMAIL PROTECTED]> wrote: > >> > >> >t_a = min(t_A, t_a) > >>

Re: [Tutor] Astonishing timing result

2008-06-25 Thread Kent Johnson
On Wed, Jun 25, 2008 at 2:06 PM, Lie Ryan <[EMAIL PROTECTED]> wrote: > On Wed, 2008-06-25 at 12:56 -0400, Kent Johnson wrote: >> On Wed, Jun 25, 2008 at 12:05 PM, Lie Ryan <[EMAIL PROTECTED]> wrote: >> >> >t_a = min(t_A, t_a) >> >t_b = min(t_A, t_b) >> >t_c = min(t_A, t_c) >> >t_d =

Re: [Tutor] Astonishing timing result

2008-06-25 Thread Lie Ryan
On Wed, 2008-06-25 at 12:56 -0400, Kent Johnson wrote: > On Wed, Jun 25, 2008 at 12:05 PM, Lie Ryan <[EMAIL PROTECTED]> wrote: > > >t_a = min(t_A, t_a) > >t_b = min(t_A, t_b) > >t_c = min(t_A, t_c) > >t_d = min(t_A, t_d) > > What is this for? It should at least be t_B, t_C, t_D.

Re: [Tutor] Astonishing timing result

2008-06-25 Thread Kent Johnson
On Wed, Jun 25, 2008 at 12:05 PM, Lie Ryan <[EMAIL PROTECTED]> wrote: >t_a = min(t_A, t_a) >t_b = min(t_A, t_b) >t_c = min(t_A, t_c) >t_d = min(t_A, t_d) What is this for? It should at least be t_B, t_C, t_D. > ## OUTPUT > # 1.02956604958 > # 1.02956604958 > # 1.02956604958 > # 1

Re: [Tutor] Astonishing timing result

2008-06-25 Thread Lie Ryan
I'm a bit curious about how you do the timing. I think there is a flaw in how you measured the time. I made this code and the result is inconclusive. ## CODE: test.py #!/usr/bin/env python import imported import time from imported import * def b(): a = 1 r = range(500) t_a, t_b, t_c, t

Re: [Tutor] Astonishing timing result

2008-06-25 Thread Kent Johnson
On Wed, Jun 25, 2008 at 1:16 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > At 07:00 PM 6/24/2008, Marilyn Davis wrote: > >> Has anyone ever timed the difference between using a function that was >> imported with: >> >> from my_module import MyFunction >> >> and: >> >> import my_module > > Here are 2

Re: [Tutor] Astonishing timing result

2008-06-24 Thread Dick Moores
At 07:00 PM 6/24/2008, Marilyn Davis wrote: Has anyone ever timed the difference between using a function that was imported with: from my_module import MyFunction and: import my_module Here are 2 comparisons: , and

Re: [Tutor] Astonishing timing result

2008-06-24 Thread Dick Moores
At 05:35 PM 6/24/2008, Kent Johnson wrote: On Tue, Jun 24, 2008 at 5:20 PM, Dick Moores <[EMAIL PROTECTED]> wrote: > Basically, I'm not worried, just curious. Not about the small differences, > but why did the use of the standardif __name__ == '__main__' result > it such speed? Because

Re: [Tutor] Astonishing timing result

2008-06-24 Thread Kent Johnson
On Tue, Jun 24, 2008 at 5:20 PM, Dick Moores <[EMAIL PROTECTED]> wrote: > Basically, I'm not worried, just curious. Not about the small differences, > but why did the use of the standardif __name__ == '__main__' result > it such speed? Because __name__ is not equal to "__main__", so you w

Re: [Tutor] Astonishing timing result

2008-06-24 Thread Dick Moores
At 04:49 PM 6/24/2008, Marilyn Davis wrote: Does this mean that if __name__ == "__main__" takes the extra time? and that that's brings t2 in line with the others? I don't think so. Please refer to the code again: . Line 21 is if __name__ == '_

Re: [Tutor] Astonishing timing result

2008-06-24 Thread Marilyn Davis
On Tue, June 24, 2008 2:06 pm, [EMAIL PROTECTED] wrote: > - Message from [EMAIL PROTECTED] - > Date: Tue, 24 Jun 2008 13:44:00 -0700 > From: Dick Moores <[EMAIL PROTECTED]> > > >> At 12:44 PM 6/24/2008, Kent Johnson wrote: >> >>> On Tue, Jun 24, 2008 at 1:43 PM, Dick Moores <[EMAIL PRO

Re: [Tutor] Astonishing timing result

2008-06-24 Thread Dick Moores
At 02:06 PM 6/24/2008, [EMAIL PROTECTED] wrote: - Message from [EMAIL PROTECTED] - Date: Tue, 24 Jun 2008 13:44:00 -0700 From: Dick Moores <[EMAIL PROTECTED]> At 12:44 PM 6/24/2008, Kent Johnson wrote: On Tue, Jun 24, 2008 at 1:43 PM, Dick Moores <[EMAIL PROTECTED]> wrote:

Re: [Tutor] Astonishing timing result

2008-06-24 Thread broek
- Message from [EMAIL PROTECTED] - Date: Tue, 24 Jun 2008 13:44:00 -0700 From: Dick Moores <[EMAIL PROTECTED]> At 12:44 PM 6/24/2008, Kent Johnson wrote: On Tue, Jun 24, 2008 at 1:43 PM, Dick Moores <[EMAIL PROTECTED]> wrote: Output: t1 is 0.000104, no function t2 is 5.87e

Re: [Tutor] Astonishing timing result

2008-06-24 Thread Dick Moores
At 12:44 PM 6/24/2008, Kent Johnson wrote: On Tue, Jun 24, 2008 at 1:43 PM, Dick Moores <[EMAIL PROTECTED]> wrote: > Output: > t1 is 0.000104, no function > t2 is 5.87e-006, function explicit > t3 is 0.000126, function imported > t1/t2 is 17.8 > t1/t3 is 0.827 > t3/t2 is 21.5 > > Now, I'd heard t

Re: [Tutor] Astonishing timing result

2008-06-24 Thread Kent Johnson
On Tue, Jun 24, 2008 at 1:43 PM, Dick Moores <[EMAIL PROTECTED]> wrote: > Output: > t1 is 0.000104, no function > t2 is 5.87e-006, function explicit > t3 is 0.000126, function imported > t1/t2 is 17.8 > t1/t3 is 0.827 > t3/t2 is 21.5 > > Now, I'd heard that code in a function runs faster than the s

[Tutor] Astonishing timing result

2008-06-24 Thread Dick Moores
I haven't done much timing using Timer from the timeit module, so maybe I haven't done this correctly, but I'm amazed at the difference in speed between importing a function and not importing it but instead putting it directly into a script. Please look at < http://py77.python.pastebin.com/f152b6