paleolimbot commented on code in PR #451:
URL: https://github.com/apache/arrow-nanoarrow/pull/451#discussion_r1587994366


##########
python/src/nanoarrow/_lib.pyx:
##########
@@ -160,68 +160,93 @@ cdef void pycapsule_array_view_deleter(object 
array_capsule) noexcept:
     ArrowFree(array_view)
 
 
-cdef object alloc_c_array_view(ArrowArrayView** c_array_view) noexcept:
+cdef object alloc_c_array_view(ArrowArrayView** c_array_view):
     c_array_view[0] = <ArrowArrayView*> ArrowMalloc(sizeof(ArrowArrayView))
     ArrowArrayViewInitFromType(c_array_view[0], NANOARROW_TYPE_UNINITIALIZED)
     return PyCapsule_New(c_array_view[0], 'nanoarrow_array_view', 
&pycapsule_array_view_deleter)
 
 
-cdef void arrow_array_release(ArrowArray* array) noexcept with gil:
-    Py_DECREF(<object>array.private_data)
-    array.private_data = NULL
-    array.release = NULL
+# Provide a way to validate that we release all references we create
+cdef int64_t pyobject_buffer_count = 0
 
+def get_pyobject_buffer_count():
+    global pyobject_buffer_count
+    return pyobject_buffer_count

Review Comment:
   I checked the generated C code and it looks like it is "just" incrementing 
and decrementing `static int64_t 
__pyx_v_9nanoarrow_4_lib_pyobject_buffer_count;` (which I don't believe is 
prohibitively expensive). I have a similar reference counting scheme in the R 
package and it has been mission critical in debugging!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to