Beginner question - How to effectively pass a large list

JCM joshway_without_spam at myway.com
Thu Dec 18 10:34:54 EST 2003


Alan Gauld <alan.gauld at btinternet.com> wrote:
> On Tue, 16 Dec 2003 16:21:00 +0800, "J.R." <j.r.gao at motorola.com>
> wrote:
>> Actually, the python is passing the identity (i.e. memory address) of each
>> parameter, and it will bind to a local name within the function.
>> 
>> Right?

> Nope.
> This is one case where understanding something of the insides of
> Python helps. Basically Python variables are dictionary entries.
> The variable values are the the dictionary values associated with
> the variable names which are the dictionary keys.

> Thus when you pass an argument to a function you are passing a
> dictionary key. When the function uses the argument it looks up
> the dictionary and uses the value found there.

> This applies to all sorts of things in Python including modules -
> a local dictionary associated with the module, and classes -
> another dictionary. Dictionaries are fundamental to how Python
> works and memory addresses per se play no part in the procedings.

You're talking about the implementation of the interpreter.  I
wouldn't have used the term "memory address" as J.R. did, as this also
implies something about the implementation, but it does make sense to
say object IDs/object references are passed into functions and bound
to names/variables.




More information about the Python-list mailing list