I'm maintaining a Python type that has been built as a Python extension using the Python C API. My question is regarding the lifetime of this "NamedArray" object. Essentially my test code looks like this:
def test_init_from_constructor(self):
"""
:return:
"""
n = NamedArray((2, 3))
self.assertIsInstance(n, NamedArray)
self.assertEqual(2, sys.getrefcount(n))
My issue is that the ref count of the newly instantiated NamedArray object is 2, yet I expect it to be 1. Where is the other reference coming from ?
This is documented under
sys.getrefcount