-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
PEP 756: Give up on copying memory #3999
Conversation
@zooba @pitrou: I tried hard to fit memory copies and conversions in PEP 756, but apparently there are too many drawbacks and most users expect/require O(1) complexity. Here is a change to give up on any kind of implicit conversion and only export what we have in O(1). It means giving up on exporting UTF-8 on CPython 3.14 which is IMO an acceptable tradeoff. You can use PyUnicode_AsUTF8AndSize() which is already available. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this change.
I don't know that referring to "most users expect" is necessarily true or helpful, but expectations will certainly be clearer.
Co-authored-by: Steve Dower <[email protected]>
Well, in the PEP 756 discussions, it seems like the majority has the expectation that an export has a O(1) complexity and would be unhappy if somehow an export can cost O(n) on a different Python version or implementation. |
I think the users we're trying to satisfy here are the ones you listed in the PEP: https://peps.python.org/pep-0756/#usage-of-pep-393-c-apis |
I guess I feel like I dominated the discussion too much and you shouldn't treat me as representing multiple users 😆
Indeed, though I'm only aware of a deep dive going into markupsafe, which did have a legitimate use for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice edits. Thank you for the clarity.
Merged, thanks for reviews. |
📚 Documentation preview 📚: https://pep-previews--3999.org.readthedocs.build/