Skip to content

Conversation

@adamreichold
Copy link
Member

The first and already discussed fix towards a resolution of #258

pyo3::Python::with_gil(|py| {
let not_contiguous = not_contiguous_array(py);
let raw_array_view = not_contiguous.as_raw_array();
assert_eq!(unsafe { raw_array_view.deref_into_view()[0] }, 1);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One downside appears to be that ndarray does not provide indexing into raw views, only dereferencing the whole view.

Copy link
Member

@kngwyu kngwyu Jan 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's not very userfriendly, but I think this is rather a downside of raw view, not that of having conversion API

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened rust-ndarray/ndarray#1151 to expand the ndarray interface.

Copy link
Member

@kngwyu kngwyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

pyo3::Python::with_gil(|py| {
let not_contiguous = not_contiguous_array(py);
let raw_array_view = not_contiguous.as_raw_array();
assert_eq!(unsafe { raw_array_view.deref_into_view()[0] }, 1);
Copy link
Member

@kngwyu kngwyu Jan 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's not very userfriendly, but I think this is rather a downside of raw view, not that of having conversion API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants