fix-ARROW-15511.patch 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. From 3f9daeb25fd471e85d584a2743f83a1abfe5fb3d Mon Sep 17 00:00:00 2001
  2. From: emkornfield <emkornfield@gmail.com>
  3. Date: Wed, 2 Feb 2022 12:26:12 +0100
  4. Subject: [PATCH] ARROW-15511: [Python][C++] Remove reference management in
  5. numpy indexer
  6. It appears all usages don't escape the scope of methods so a strong reference should already be in place.
  7. This is necessary because Ndarray1DIndexer can be used without the GIL held.
  8. Closes #12314 from emkornfield/ARROW-15511
  9. Authored-by: emkornfield <emkornfield@gmail.com>
  10. Signed-off-by: Antoine Pitrou <antoine@python.org>
  11. ---
  12. cpp/src/arrow/python/numpy_internal.h | 3 +--
  13. 1 file changed, 1 insertion(+), 2 deletions(-)
  14. diff --git a/cpp/src/arrow/python/numpy_internal.h b/cpp/src/arrow/python/numpy_internal.h
  15. index 973f577cb1320..50d1a0fcb75d4 100644
  16. --- a/cpp/src/arrow/python/numpy_internal.h
  17. +++ b/cpp/src/arrow/python/numpy_internal.h
  18. @@ -43,12 +43,11 @@ class Ndarray1DIndexer {
  19. explicit Ndarray1DIndexer(PyArrayObject* arr) : Ndarray1DIndexer() {
  20. arr_ = arr;
  21. DCHECK_EQ(1, PyArray_NDIM(arr)) << "Only works with 1-dimensional arrays";
  22. - Py_INCREF(arr);
  23. data_ = reinterpret_cast<uint8_t*>(PyArray_DATA(arr));
  24. stride_ = PyArray_STRIDES(arr)[0];
  25. }
  26. - ~Ndarray1DIndexer() { Py_XDECREF(arr_); }
  27. + ~Ndarray1DIndexer() = default;
  28. int64_t size() const { return PyArray_SIZE(arr_); }