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

Add PyMemoryView type #3514

Merged
merged 4 commits into from Oct 15, 2023
Merged

Add PyMemoryView type #3514

merged 4 commits into from Oct 15, 2023

Conversation

messense
Copy link
Member

Provides a safe way to return a memoryview object to Python.

@adamreichold
Copy link
Member

What is the relation of this to #2711 and #2792?

@messense
Copy link
Member Author

What is the relation of this to #2711 and #2792?

Ah, I was searching for memoryview and didn't find the existing issue. 😂

@messense
Copy link
Member Author

IMO this PR is a very limited version of #2792 that just opens door to return memoryview object, the existing PyBuffer already handles the need for accessing objects that implements buffer protocol in Rust (at least for my use case).

@adamreichold
Copy link
Member

this PR is a very limited version of #2792

Ok, so we leave the original issue open.

Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Thanks, looks good to me! Perhaps consider adding unit tests for the TryFrom implementations before merging? Otherwise please feel free to merge :)

@messense
Copy link
Member Author

Perhaps consider adding unit tests for the TryFrom implementations before merging?

Added in f4e64aa, but it looks like the ergonomics of the new TryFrom impls are not great because they collides with PyTryFrom::try_from so users need to disambiguate them manually.

@davidhewitt
Copy link
Member

Ah yes, we should probably remove PyTryFrom. #3516

@davidhewitt davidhewitt added this pull request to the merge queue Oct 15, 2023
Merged via the queue into PyO3:main with commit f12f928 Oct 15, 2023
32 checks passed
@messense messense deleted the memoryview branch October 16, 2023 02:54
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.

None yet

3 participants