Skip to content
New issue

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

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

Already on GitHub? # to your account

Buffer protocol updates to support object references, custom release method #772

Merged
merged 2 commits into from
Feb 21, 2020

Conversation

andrewwhitehead
Copy link
Contributor

This PR doesn't cover the buffer refactoring mentioned in #657 for example, but it allows for implementors to avoid having the exporter dropped while Python is holding a memoryview referencing it. Leaving as a draft because I'm not sure what the impact would be on existing implementations.

…ures to pass PyClassShell

Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
@kngwyu
Copy link
Member

kngwyu commented Feb 21, 2020

Thank you.

it allows for implementors to avoid having the exporter dropped while Python is holding a memoryview referencing it.

So you mean this PR enables (*view).obj = slf.as_ptr();?
It's nice 👍

The only concern is the conflict with #770, but I can fix it myself.
It's OK to merge this PR when you're ready.


{
let _py = Python::acquire_gil().python();
drop(buf);
Copy link
Member

Choose a reason for hiding this comment

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

This test is nice 👍

@andrewwhitehead
Copy link
Contributor Author

@kngwyu That's great, yes I was also concerned about the conflict with that other PR.

Incidentally, my use case is a memory buffer with a private key which I want to zero out as soon as there's no more references to it, but not before then.

@andrewwhitehead andrewwhitehead marked this pull request as ready for review February 21, 2020 03:53
@kngwyu
Copy link
Member

kngwyu commented Feb 21, 2020

Thank you!

@kngwyu kngwyu merged commit 90b14fb into PyO3:master Feb 21, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants