Is 'everything' a refrence or isn't it?

Terry Hancock hancock at
Thu Jan 5 23:18:39 EST 2006

On Fri, 06 Jan 2006 12:01:09 +1100
"Steven D'Aprano" <steve at> wrote:

> On Wed, 04 Jan 2006 22:51:03 -0500, Mike Meyer wrote:
> >> And if you only ever passed immutable objects around,
> >you would > think Python was call by value.
> > 
> > You might. Then again, you might also understand the
> > concepts well enough to realize that there isn't any
> > difference between CBR and CBV when you're passing
> > immutable objects.
> Consider this:
> def do_nothing(x):
>     pass
> huge_tuple = (None,) * 10000**4
> do_nothing(huge_tuple)
> If Python made a copy of huge_tuple before passing it to
> the function, you would notice.

Which succinctly demonstrates precisely why a newbie
*should* be told that Python passes references instead of
values. Without this basic knowledge, the newcomer can't
possibly be expected to make intelligent choices of

But it should probably also be made clear that
"reference" means a label assigned to an object, and not a
variable containing a memory location (which is what a C
"pointer" is).

The reference is usually a simple name, but it can also be
an container expression following list, dictionary,
or class instance (spam, spam[0], spam['eggs'], or
spam.ham, for example).  Not tuple or string because they
are immutable, and so don't have assignable references.


Terry Hancock (hancock at
Anansi Spaceworks

More information about the Python-list mailing list