What makes functions special?

Ben Finney ben+python at benfinney.id.au
Sun Jul 10 00:41:27 CEST 2011

Eric Snow <ericsnowcurrently at gmail.com> writes:

> A tracker issue [1] recently got me thinking about what makes
> functions special.

As you describe, functions are special for your scenario because a
function definition needs to result in executable code as an object.

> Definition time actually happens during compile time, but it has its
> own label to mark the contrast with execution time. So why do
> functions get this special treatment?

You answer this question.

> No other objects have code objects. No other objects in Python have
> this special optimization.

Yes. The two facts are directly related.

> Maybe I am missing something, or maybe it is super obvious, but isn't
> this a critical point?

What is the crisis (“a stark change from one state to another”) that
you're referring to by “a critical point”?

Yes, functions are different and are treated differently. What's your

> From the docs, the code objects in of function objects are the latter,
> but the optimization expectation is not clearly indicated. Are there
> other motivations behind code objects that I am missing? Am I wrong
> about the optimization expectation?

What optimisation expectation?

> Thoughts?

I think yours need to be expressed more explicitly; I'm not seeing the
issue that concerns you.

 \        “The reason we come up with new versions is not to fix bugs. |
  `\                     It's absolutely not.” —Bill Gates, 1995-10-23 |
_o__)                                                                  |
Ben Finney

More information about the Python-list mailing list