On Jan 7, 2:02 am, Steven D'Aprano <ste...@remove.this.cybersource.com.au> wrote:
> In Python code, there are no references and no dereferencing. The why does CPython keep track of reference counts? > You can't, because Python doesn't have references. In a language with > references, that's easy. Python does not 'pass-by-reference' as Fortran or Pascal do. > It's harder (impossible?) to write a version that will operate on > arbitrary types, but that's statically typed languages for you. In Python an assignment (re)binds the name to another value. You can certainly write a swap method for mutable types. But you cannot use the assignment operator to swap the values. > No no no, lists and tuples store *objects*. >>> a = 123456789 >>> b = [a] >>> c = [a] >>> d = [a, a] >>> b[0] is a True >>> c[0] is a True >>> d[0] is a True >>> d[1] is a True Where is the object 'a' stored? -- http://mail.python.org/mailman/listinfo/python-list