What makes functions special?
ben+python at benfinney.id.au
Sun Jul 10 02:38:28 CEST 2011
Eric Snow <ericsnowcurrently at gmail.com> writes:
> On Sat, Jul 9, 2011 at 4:41 PM, Ben Finney <ben+python at benfinney.id.au> wrote:
> > Eric Snow <ericsnowcurrently at gmail.com> writes:
> >> No other objects have code objects. No other objects in Python have
> >> this special optimization.
> > Yes. The two facts are directly related.
> > Yes, functions are different and are treated differently. What's
> > your question?
> My point is that functions are special in Python because they provide
> a built in optimization via the special execution of code objects.
Functions are special because they define a code object.
> I would like to know if it is really that big a deal
Is *what* really that big a deal?
Perhaps this could be clearer if you'd describe what it is that
surprises you, and how you'd expect it to be different.
> and if the optimized execution of code objects is a CPython
> implementation detail or a specification of the language.
I don't know that it's a specification. But functions result in code
objects, and other statements don't; I am not seeing why treating them
differently is surprising.
\ “I see little commercial potential for the Internet for at |
`\ least ten years.” —Bill Gates, 1994 |
More information about the Python-list