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 same code not in > a function, but even so I was surprised at the t1/t2 ratio of 17.8. > > The astonishing (to me, anyway) result was the t3/t2 ratio. I had no idea > that importing from mycalc slowed a script down at all, let alone by a > factor of 21!
Note that t1 and t3 are pretty close to each other. Perhaps you should be suspicious of t2. What if __name__ != '__main__' ? Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor