On Sep 3, 11:55 pm, alex23 <wuwe...@gmail.com> wrote:
> Sean DiZazzo <half.ital...@gmail.com> wrote:
> > What are you using to test the scripts?  I could be completely wrong,
> > but I find it hard to believe that the second version is much (if any)
> > faster than the first.  Then again, I don't know much about the
> > internals...
>
> Sorry, Sean, unfortunately you are wrong, although it's understandable
> that you've missed this.
>
> The lookup of locally scoped references is a lot faster than that of
> global ones, primarily due to the lookup order: it first checks the
> local scope and then out through surrounding scopes _before_ the
> global scope.
>
> So yes, depending on the nature of your code, its quite conceivable to
> find distinct performance differences between code using the __main__
> idiom and code without.

Interesting.  I guess at some point I should try to understand what is
going on under the covers.  Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to