westonpace commented on PR #12590:
URL: https://github.com/apache/arrow/pull/12590#issuecomment-1109566601

   To be fair, this is a concern that is rather unique to `set_memory_pool`.  
Generally, when we call a C++ function and pass some input, we can assume the 
C++ function will make a copy (or borrow python references) for whatever it 
needs to use.  For example:
   
   ```
   def make_my_array():
     my_list = [1, 2, 3]
     return pa.array(my_list)
   ```
   
   Here I don't have to worry about the fact that `my_list` goes out of scope 
at the end of the function.  The function call `pa.array` will make a copy of 
the values.  This ensures that the array will work properly even after the 
function returns.
   
   However, as I said, `pa.set_memory_pool` is unique (if you want to open a PR 
to the pyarrow docs it might be good to mention this on the docs for 
`set_memory_pool`).  In the C++ definition for the call we can see:
   
   ```
   ARROW_PYTHON_EXPORT void set_default_memory_pool(MemoryPool* pool);
   ```
   
   Since the method receives a raw pointer we generally assume that it is not 
extending the lifetime of the pointed-to value.  Again, this is rather unique.  
We don't have a lot of public API setters that receive a raw pointer.


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