[Numpy-discussion] Multidimension array access in C via Python API
Eric Moore
ewm at redtetrahedron.org
Mon Apr 4 17:14:27 EDT 2016
Yes, PySlice_New(NULL, NULL, NULL) is the same as ':'. Depending on what
exactly you want to do with the column once you've extracted it, this may
not be the best way to do it. Are you absolutely certain that you actually
need a PyArrayObject that points to the column?
Eric
On Mon, Apr 4, 2016 at 3:59 PM, mpc <matt.p.conte at gmail.com> wrote:
> Thanks for responding.
>
> It looks you made/found these yourself since I can't find anything like
> this
> in the API. I can't believe it isn't, so convenient!
>
> By the way, from what I understand, the ':' is represented as
> *PySlice_New(NULL, NULL, NULL) *in the C API when accessing by index,
> correct?
>
>
> Therefore the final result will be something like:
>
> *PyObject* first_column_tuple = PyTuple_New(2);
> PyTuple_SET_ITEM(first_column_tuple, 0, PySlice_New(NULL, NULL, NULL));
> PyTuple_SET_ITEM(first_column_tuple, 1, PyInt_FromLong(0));
> PyObject* first_column_buffer = PyObject_GetItem(src_buffer,
> first_column_tuple);
> *
>
>
>
> --
> View this message in context:
> http://numpy-discussion.10968.n7.nabble.com/Multidimension-array-access-in-C-via-Python-API-tp42710p42715.html
> Sent from the Numpy-discussion mailing list archive at Nabble.com.
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20160404/a0c46215/attachment.html>
More information about the NumPy-Discussion
mailing list