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. -- http://mail.python.org/mailman/listinfo/python-list