bkietz commented on pull request #9274: URL: https://github.com/apache/arrow/pull/9274#issuecomment-763833521
I think the best way to resolve this issue is to avoid direct instances of derived classes of FunctionOptions in Cython, since Cython inappropriately applies `offsetof`. For example, note that the warning is emitted for [MinMaxOptions](https://github.com/apache/arrow/blob/fdc63acdb68adade0d68e232dfcc892dc0ecf700/python/pyarrow/_compute.pyx#L670) but not for [SetLookupOptions](https://github.com/apache/arrow/blob/fdc63acdb68adade0d68e232dfcc892dc0ecf700/python/pyarrow/_compute.pyx#L732) (where the options are held by unique_ptr rather than being a direct member). I'd recommend the following approach: rewrite `_compute.pyx::FunctionOptions` to hold a `shared_ptr[CFunctionOptions]`, and let the `cdef` classes acquire a non owning pointer to the appropriate FunctionOptions subclass. For example: `_compute.pxd` ```python cdef class FunctionOptions(_Weakrefable): cdef: shared_ptr[CFunctionOptions] options cdef const CFunctionOptions* get_options(self) except NULL ``` `_compute.pyx` ```python cdef class _CastOptions(FunctionOptions): cdef: const CCastOptions* cast_options __slots__ = () # avoid mistakingly creating attributes cdef const CFunctionOptions* get_options(self) except NULL: return self.cast_options ``` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
