bkietz commented on a change in pull request #9274: URL: https://github.com/apache/arrow/pull/9274#discussion_r562634717
########## File path: python/pyarrow/_compute.pyx ########## @@ -481,88 +481,89 @@ cdef class FunctionOptions(_Weakrefable): cdef class _CastOptions(FunctionOptions): cdef: - CCastOptions options + unique_ptr[CCastOptions] options __slots__ = () # avoid mistakingly creating attributes cdef const CFunctionOptions* get_options(self) except NULL: - return &self.options + return self.options.get() def _set_options(self, DataType target_type, allow_int_overflow, allow_time_truncate, allow_time_overflow, allow_float_truncate, allow_invalid_utf8): + self.options.reset(new CCastOptions()) self._set_type(target_type) if allow_int_overflow is not None: - self.allow_int_overflow = allow_int_overflow + deref(self.options).allow_int_overflow = allow_int_overflow if allow_time_truncate is not None: - self.allow_time_truncate = allow_time_truncate + deref(self.options).allow_time_truncate = allow_time_truncate if allow_time_overflow is not None: - self.allow_time_overflow = allow_time_overflow + deref(self.options).allow_time_overflow = allow_time_overflow if allow_float_truncate is not None: - self.allow_float_truncate = allow_float_truncate + deref(self.options).allow_float_truncate = allow_float_truncate if allow_invalid_utf8 is not None: - self.allow_invalid_utf8 = allow_invalid_utf8 + deref(self.options).allow_invalid_utf8 = allow_invalid_utf8 def _set_type(self, target_type=None): if target_type is not None: - self.options.to_type = ( + deref(self.options).to_type = ( (<DataType> ensure_type(target_type)).sp_type ) def _set_safe(self): - self.options = CCastOptions.Safe() + self.options.reset(new CCastOptions(CCastOptions.Safe())) Review comment: I think this is the most efficient way to write this in cython. ---------------------------------------------------------------- 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: us...@infra.apache.org