[PYTHON MATRIX-SIG] Re: may be a bug
Tser-Yuan (Brian) Yang
tbyang@icf.llnl.gov
Fri, 21 Jun 1996 16:04:27 -0700 (PDT)
Brian Yang wrote:
> The following may have been posted or even corrected. If so, I apologize
> for sending junk mail.
> >>> from Numeric import *
> >>> a=array((1,2))
> >>> import sys
> >>> sys.getrefcount(a)
> 2
> >>> a
> 1 2
> >>> sys.getrefcount(a)
> 5
> >>> b=1
> >>> sys.getrefcount(a)
> 4
First, I should correct myself:
sys.getrefcount(a) should still be 5 after b=1, since assignment does not
return a value.
Some experiment showed that the extra reference counts are held by
something in ArrayPrinter.py, because I commented out the following line
in numeric.py:
#from ArrayPrinter import arrayToString
#set_print_function(arrayToString)
and it hehaves like the following
>>> from Numeric import *
>>> a=array((1,3))
>>> a
array([1,3], 'l')
>>> import sys
>>> sys.getrefcount(a)
3
>>> 1
1
>>> sys.getrefcount(a)
2
Brian Yang
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================