westonpace commented on code in PR #12590:
URL: https://github.com/apache/arrow/pull/12590#discussion_r855641281


##########
cpp/src/arrow/python/common.h:
##########
@@ -180,6 +180,9 @@ class ARROW_PYTHON_EXPORT OwnedRefNoGIL : public OwnedRef {
   explicit OwnedRefNoGIL(PyObject* obj) : OwnedRef(obj) {}
 
   ~OwnedRefNoGIL() {
+    if (obj() == NULLPTR) {

Review Comment:
   This particular change is not specific to finalization.  For example:
   
   ```
   void Foo(PyObject* obj) {
       OwnedRefNoGIL obj_ref(obj);
       Bar(std::move(obj_ref));
       // At the close of this method `~OwnedRefNoGIL` will be called on 
`obj_ref` which is no longer valid.  We shouldn't
       // bother grabbing the GIL for no reason.
   }
   ```
   
   The part that is related to finalization is the `~PythonUdf` part (and we 
already have a comment there)`.



-- 
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