Beginner question - How to effectively pass a large list

Alan Gauld alan.gauld at btinternet.com
Wed Dec 17 13:46:10 EST 2003


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.

HTH

Alan G.

Author of the Learn to Program website
http://www.freenetpages.co.uk/hp/alan.gauld




More information about the Python-list mailing list