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


##########
python/pyarrow/tensor.pxi:
##########
@@ -282,10 +292,8 @@ strides: {0.strides}""".format(self)
             buffer.readonly = 0
         else:
             buffer.readonly = 1
-        # NOTE: This assumes Py_ssize_t == int64_t, and that the shape
-        # and strides arrays lifetime is tied to the tensor's
-        buffer.shape = <Py_ssize_t *> &self.tp.shape()[0]
-        buffer.strides = <Py_ssize_t *> &self.tp.strides()[0]
+        buffer.shape = <Py_ssize_t *> cp.PyBytes_AsString(self._ssize_t_shape)
+        buffer.strides = <Py_ssize_t *> 
cp.PyBytes_AsString(self._ssize_t_strides)

Review Comment:
   I confirm it does not work:
   ```
     Error compiling Cython file:
     ------------------------------------------------------------
     ...
             buffer.obj = self
             if self.tp.is_mutable():
                 buffer.readonly = 0
             else:
                 buffer.readonly = 1
             buffer.shape = <Py_ssize_t *> self._ssize_t_shape
                            ^
     ------------------------------------------------------------
   
     pyarrow/tensor.pxi:295:23: Python objects cannot be cast to pointers of 
primitive types
   ```
   
   and also:
   ```
     Error compiling Cython file:
     ------------------------------------------------------------
     ...
             buffer.obj = self
             if self.tp.is_mutable():
                 buffer.readonly = 0
             else:
                 buffer.readonly = 1
             buffer.shape = self._ssize_t_shape
                                ^
     ------------------------------------------------------------
   
     pyarrow/tensor.pxi:295:27: Cannot convert Python object to 'Py_ssize_t *'
   ```



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