What makes functions special?
tjreedy at udel.edu
Sun Jul 10 02:21:28 CEST 2011
On 7/9/2011 2:28 PM, Eric Snow wrote:
> A tracker issue  recently got me thinking about what makes
> functions special. The discussion there was regarding the distinction
> between compile time (generation of .pyc files for modules and
> execution of code blocks), [function] definition time, and [function]
> execution time. Definition time actually happens during compile time,
Not true. For main modules, execution of each statement immediately
follows compilation, but not for other modules, where compilation and
caching of code objects may happen years before the function object is
> Functions are a special case in Python for providing a more optimized
> execution of a code block in pure Python code. And how is that? When
> the function is defined, a code object is generated for the function
> body along with a few "static" details that will be used during
> execution. No other objects have code objects. No other objects in
> Python have this special optimization.
A .pyc file is a serialized code object for a module.
As for the rest, I am not sure what you are asking.
More information about the Python-list