On 7/9/2011 2:28 PM, Eric Snow wrote:
A tracker issue [1] 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 created.
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. Terry Reedy -- http://mail.python.org/mailman/listinfo/python-list