alippai commented on code in PR #48391:
URL: https://github.com/apache/arrow/pull/48391#discussion_r2599448669
##########
python/pyarrow/src/arrow/python/numpy_to_arrow.cc:
##########
@@ -74,6 +81,37 @@ using internal::NumPyTypeSize;
namespace {
+#if NPY_ABI_VERSION >= 0x02000000
+
+// NumPy exposes StringDType helpers in the C-API table from version 2.0
onward,
+// but the corresponding macros are only available when compiling against a
+// 2.0+ feature level. Arrow still targets an older feature level, so provide
+// local wrappers that call the C-API entries directly.
+
+inline npy_string_allocator* ArrowNpyString_acquire_allocator(
+ const PyArray_StringDTypeObject* descr) {
+ using Func = npy_string_allocator* (*)(const PyArray_StringDTypeObject*);
+ auto func = reinterpret_cast<Func>(PyArray_API[316]);
Review Comment:
This is a reimplementation of the public api as the numpy api version used
in pyarrow was below <2.0 and these were “hidden”. This way the code compiles
with both old and new numpy. I didn’t find a better example in pyarrow how to
onboard new API. The alternative is dropping the numpy 1.26 support (which
might be allowed if pyarrow follows SPEC 0)
--
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]