-
Notifications
You must be signed in to change notification settings - Fork 4
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
Support PyO3's abi3-py38
feature
#8
base: main
Are you sure you want to change the base?
Conversation
@termoshtt I was just about to prepare a similar PR to allow using Can I help in any way so we could get this landed? |
My main concern is here. Although it is acceptable for this crate, I thought that I need to seek more better way and kept this PR as draft. As a result, we use python-version specific packaging in our project and this PR is left as it is. If you now do not know a way to avoid it, I can merge this PR. |
I understand your concern and would also rather prevent the additional memcpy. When digging into the issue yesterday I ended up with the feeling that PyO3 relies on My suggestion would therefore be something like this: if self.0.is_instance_of::<PyString>() {
- return visitor.visit_str(&self.0.extract::<String>()?);
+ return visitor.visit_str(&self.0.downcast()?.to_cow()?);
} This way, we should be able to keep the current zero-copy implementation where possible and only add the addional memcpy when However, for avoiding the memcpy at all costs in a use case, using python-version specific packaging will still be the better way as What do you think? |
@termoshtt What are your thoughts on this? |
extract::<&str>
is replaced byextract::<String>
. This means we take additional memcpy, but this crate is not intended to avoid this cost.