[Scipy-tickets] [SciPy] #543: Scipy appears to be incorrectly managing the ref count of None

SciPy scipy-tickets@scipy....
Wed Nov 21 14:52:17 CST 2007


#543: Scipy appears to be incorrectly managing the ref count of None
------------------------------------+---------------------------------------
 Reporter:  steffeat                |        Owner:  somebody
     Type:  defect                  |       Status:  closed  
 Priority:  normal                  |    Milestone:  0.7     
Component:  Other                   |      Version:  devel   
 Severity:  normal                  |   Resolution:  wontfix 
 Keywords:  None Py_None ref count  |  
------------------------------------+---------------------------------------
Changes (by rkern):

  * status:  new => closed
  * resolution:  => wontfix

Comment:

 I'm not sure this is a problem of scipy in particular:

 {{{

 In [9]: sys.getrefcount(None)
 Out[9]: 7460

 In [10]: import optparse

 In [11]: sys.getrefcount(None)
 Out[11]: 7460

 In [12]: reload(optparse)
 Out[12]: <module 'optparse' from
 '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/optparse.pyc'>

 In [13]: sys.getrefcount(None)
 Out[13]: 7629

 In [14]: reload(optparse)
 Out[14]: <module 'optparse' from
 '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/optparse.pyc'>

 In [15]: sys.getrefcount(None)
 Out[15]: 7646

 In [16]: reload(optparse)
 Out[16]: <module 'optparse' from
 '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/optparse.pyc'>

 In [17]: sys.getrefcount(None)
 Out[17]: 7663

 In [18]: reload(optparse)
 Out[18]: <module 'optparse' from
 '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/optparse.pyc'>

 In [19]: sys.getrefcount(None)
 Out[19]: 7680

 In [20]: reload(optparse)
 Out[20]: <module 'optparse' from
 '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/optparse.pyc'>

 In [21]: sys.getrefcount(None)
 Out[21]: 7629

 }}}

 However, I do not see it with scipy:

 {{{

 In [23]: import scipy

 In [24]: sys.getrefcount(None)
 Out[24]: 8021

 In [25]: reload(scipy)
 Out[25]: <module 'scipy' from
 '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-
 packages/scipy-0.7.0.dev3497-py2.5-macosx-10.3-fat.egg/scipy/__init__.pyc'>

 In [26]: sys.getrefcount(None)
 Out[26]: 8021

 In [27]: reload(scipy)
 Out[27]: <module 'scipy' from
 '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-
 packages/scipy-0.7.0.dev3497-py2.5-macosx-10.3-fat.egg/scipy/__init__.pyc'>

 In [28]: sys.getrefcount(None)
 Out[28]: 8021

 In [29]: reload(scipy)
 Out[29]: <module 'scipy' from
 '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-
 packages/scipy-0.7.0.dev3497-py2.5-macosx-10.3-fat.egg/scipy/__init__.pyc'>

 In [30]: sys.getrefcount(None)
 Out[30]: 8021

 }}}

 I don't think this is a problem. None will never disappear until the
 process exits. The deletion of a module object is always an ill-defined
 thing, so I'm not too surprised that the refcount of None does strange
 things.

 If you find that this causes an actual problem with your code, please
 reopen this ticket.

-- 
Ticket URL: <http://scipy.org/scipy/scipy/ticket/543#comment:1>
SciPy <http://www.scipy.org/>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list