[Tutor] Python and memory allocation

Danny Yoo dyoo at hashcollision.org
Thu Oct 24 19:59:54 CEST 2013


> And does python being an interpreted language have to do anything with
this?

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.

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.  (
http://root.cern.ch/drupal/content/cling)

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.


Coming back to your original question: take a brief glance at:


http://doc.pypy.org/en/latest/translation.html#escape-analysis-and-stack-allocation

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20131024/2e784abd/attachment.html>


More information about the Tutor mailing list