pitrou commented on code in PR #40565:
URL: https://github.com/apache/arrow/pull/40565#discussion_r1530353630


##########
python/pyarrow/src/arrow/python/arrow_to_pandas.cc:
##########
@@ -620,37 +620,42 @@ inline Status ConvertAsPyObjects(const PandasOptions& 
options, const ChunkedArra
   using ArrayType = typename TypeTraits<Type>::ArrayType;
   using Scalar = typename MemoizationTraits<Type>::Scalar;
 
-  ::arrow::internal::ScalarMemoTable<Scalar> memo_table(options.pool);
-  std::vector<PyObject*> unique_values;
-  int32_t memo_size = 0;
-
-  auto WrapMemoized = [&](const Scalar& value, PyObject** out_values) {
-    int32_t memo_index;
-    RETURN_NOT_OK(memo_table.GetOrInsert(value, &memo_index));
-    if (memo_index == memo_size) {
-      // New entry
-      RETURN_NOT_OK(wrap_func(value, out_values));
-      unique_values.push_back(*out_values);
-      ++memo_size;
-    } else {
-      // Duplicate entry
-      Py_INCREF(unique_values[memo_index]);
-      *out_values = unique_values[memo_index];
-    }
-    return Status::OK();
-  };
-
-  auto WrapUnmemoized = [&](const Scalar& value, PyObject** out_values) {
-    return wrap_func(value, out_values);
-  };
+  std::shared_ptr<::arrow::internal::ScalarMemoTable<Scalar>> memo_table = 
nullptr;

Review Comment:
   shared_ptr is overkill for this. You can use `std::optional`, or at worse 
`std::unique_ptr`.



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