why a main() function?
Fredrik Lundh
fredrik at pythonware.com
Tue Sep 19 07:47:28 EDT 2006
"Diez B. Roggisch" wrote:
>> There is another secondary advantage: the code inside a function runs
>> faster (something related is true for C programs too). Usually this
>> isn't important, but for certain programs they can go 20%+ faster.
>
> I totally fail to see why that should be the case - for python as well as
> for C.
>
> So - can you explain that a bit more, or provide resources to read up on it?
Python stores local variables in an indexed array, but globals in a dictionary.
Looking things up by index is faster than looking them up by name.
Not sure what the C thing is; C doesn't really support putting *code* outside
functions. Maybe he was thinking about static vs. auto variables ?
</F>
More information about the Python-list
mailing list