<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">> And does python being an interpreted language have to do anything with this?<div><br></div><div>I have to interrupt: you mean to say: "And does the C implementation of Python (CPython) have to do anything with this?". There are several implementations of Python out there. Not all of them use an interpreter in the sense that you're thinking of. PyPy and Jython are two concrete examples of Python implementations.</div>
<div><br></div><div>As soon as there are at least two _implementations_ of a language which use different strategies for evaluation, the term "interpreted language" loses meaning. It you consider more closely, even C and C++ can be evaluated with an interpreter. And interpreting C is not as silly as it sounds at first. Look at Cling, for example. (<a href="http://root.cern.ch/drupal/content/cling">http://root.cern.ch/drupal/content/cling</a>)</div>
<div><br></div><div>So try to avoid saying that Python is an interpreted language. "Python has an interpreter" would be a better statement. Try to avoid saying the term "interpreted language" too: it's a conceptual type error. Languages have implementations: they are not themselves implementations.</div>
<div><br></div><div><br></div><div>Coming back to your original question: take a brief glance at:</div><div><br></div><div> <a href="http://doc.pypy.org/en/latest/translation.html#escape-analysis-and-stack-allocation">http://doc.pypy.org/en/latest/translation.html#escape-analysis-and-stack-allocation</a><br>
</div><div><br></div><div>That is, there are implementations (at least one in PyPy) that will try to automatically do the stack allocation if it can reason that the values won't escape out of the scope. But allocation is an implementation detail that the Python language does not expose to make life nicer for Python programmers.</div>
</div></div></div>