Automatic debugging of copy by reference errors?

Niels L Ellegaard niels.ellegaard at gmail.com
Sat Dec 9 00:22:53 EST 2006


Is there a module that allows me to find errors that occur due to copy
by reference? I am looking for something like the following:

>>> import mydebug
>>> mydebug.checkcopybyreference = True
>>> a=2
>>> b=[a]
>>> a=4
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
CopyByReferenceError: Variable b refers to variable a, so please do not
change variable a.

Does such a module exist?
Would it be possible to code such a module?
Would it be possible to add the functionality to array-copying in
numpy?
What would be the extra cost in terms of memory and CPU power?

I realize that this module would disable some useful features of the
language. On the other hand it could be helpful for new python users.

                                         Niels




More information about the Python-list mailing list