Terminology: "reference" versus "pointer"

Chris Angelico rosuav at gmail.com
Sun Sep 13 20:58:39 EDT 2015


On Mon, Sep 14, 2015 at 10:30 AM, Akira Li <4kir4.1i at gmail.com> wrote:
> "Naming and binding" is the title from the Python language reference
> https://docs.python.org/3/reference/executionmodel.html#naming-and-binding
>
> Otherwise, I agree with you ("name" is better here).

Ah, gotcha. That's talking in much broader scope, so "naming" makes a
bit more sense there. In any case, I can't think of a better term for
it in the full context.

>> Until the moment when dependencies[dep] is requested for some new
>> value of dep, the list *does not exist*. It is constructed anew.
>> Obviously the end result of this is a dict of lists, and since those
>> lists aren't accessible from anywhere else, it makes fine sense to
>> talk about those lists as being "contained within" the (default)dict;
>> but they clearly didn't exist until they were poked at. They're
>> Heisenburg's Lists, I guess...
>
> lists are _mutable_ in Python.

So? Objects are objects. Some of them have no means of changing their
values, while others do. But the Python object model is absolutely the
same for all of them; it's not "pass by value for immutables, pass by
reference for mutables" as some have tried to claim. Immutable objects
have values and identities; the only difference is that the compiler
is allowed to constant-fold, using the same string "hello" in each of
the three places where such a string comes up, or sharing the tuple
(1,2,None) across usages.

ChrisA



More information about the Python-list mailing list