On 05/08/2014 01:06 PM, Marko Rauhamaa wrote:
Terry Reedy <tjre...@udel.edu>:

On Thu, May 8, 2014 at 6:07 PM, Joseph Martinot-Lagarde
<joseph.martinot-laga...@m4x.org> wrote:
For me, names bound to values is the same concept as pointer
pointing to memory.

You are missing a level of indirection. In CPython, a name (always in
some namespace) represents a pointer to a pointer. The first pointer
is calculated as an offset from the base pointer of the namespace. For
a C array namespace (used for functions), the offset is constant (for
that function and namespace). For a python dict namespace, the offset
is calculated from the hash of the name, the size of the dict, and the
previous contents of the hash table. This complication allows the
namespace to grow and shrink. In either case, the second pointer if
overwritten to 'rebind' the name.

Terry, you are talking about an implementation. Joseph is talking about
the concept.

You can tell a C programmer that a Python variable always holds a
pointer to an object, and they get the idea right away ("Oh, so '.' in
Python is the same as '->' in C") and start producing efficient, correct
Python code.

Right up until they want to dereference.

--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to