Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop as_cell_slice and add raw array views instead #260

Merged
merged 2 commits into from
Jan 22, 2022
Merged

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.

2 participants