Most efficient way to write data out to a text file?

Peter Hansen peter at engcorp.com
Sat Jun 29 16:25:52 EDT 2002


James Kew wrote:
> 
> "Dave Kuhlman" <dkuhlman at rexx.com> wrote in message
> news:afkv73$f2274$1 at ID-139865.news.dfncis.de...
> 
> > candiazoo at attbi.com wrote:
> > > 4) I localized constants I was using in boolean
> > > tests (there were declared at the beginning of the module, I moved
> > > them to the function call just before the loop).
> >
> > Is finding things in globals slower than finding them in locals?
> 
> Yes: you have to look, and fail to find, in the locals before you look in
> the globals.

I'm no expert in this, but that doesn't sound right.  Locals are
indexed, not searched in a dictionary.  The compiler decides if
something is local, not the runtime.  I think you're confusing 
the two-level lookup with the fact that for non-locals, first it
looks in globals, then in the builtins.  (Hope I got that right.)

-Peter



More information about the Python-list mailing list