June 2000
Intermediate to advanced
556 pages
8h 45m
English
Python uses a memory management scheme known as reference counting. For each object in the system, Python keeps track of how many variables reference that object. When the number of references to an object shrinks to zero, the memory used by the object is reclaimed or garbage collected.
The fact that variables are nothing more than references to objects is a very important one. Consider the following interactive Python session.
CD-ROM reference=6028.txt >>> x = [1,2,3] >>> print x [1,2,3] >>> y = x >>> print y [1, 2, 3]
The point here is that although both x and y will print the list [1,2,3], there is only one list. The variables x and y reference the same object. A diagram will help illustrate what is going on here. ...
Read now
Unlock full access