-
Notifications
You must be signed in to change notification settings - Fork 6
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
API with a leading underscore #58
Comments
[OT: Instead of "minor release" (which is ambiguous to people who are used to different styles of versioning), we usually say "feature release", to be distinguished from "bugfix release" (which varies in the third number, e.g. 3.x.y -> 3.x.(y+1)).] |
Would you mind to elaborate the title? I'm not sure what is the problem here? Is the problem that private and internal functions are used in the wild? Is the problem that the backward compatibility contract is unclear just by looking at a function name, especially the name starting with _Py? The Python C API documentation mentioned and/or documented many private and/or internal functions:
Does it matter if a function is documented? Tested? Or just if it's used at least once in the wild? |
The problem is that we did not always clearly say that the underscore means internal, and both users and core devs have interpreted it in various ways in the past -- from Cython relying on the API not breaking in bugfix releases, to PEPs like 523 or 590 adding underscored API intended for external use, treating the underscore as a vague warning. IMO it's good that we now clearly say they're private and users should not use them.
Yes, I think it does. If you're seeking a perfect solution to this problem, well, I do not have it. I merely try to work towards one. |
That's not the history as I remember it. A leading underscore was always considered an internal CPython API. As an extension, you were allowed to use it but don't be surprised if it breaks or disappears. I don't think we were unclear about that. I suppose we made a mistake in not pushing back earlier when we knew people were using these APIs and when people became upset when they broke. Instead of saying "sorry, that's an internal API" we tried to maintain the compatibility and not break it if possible. That was the pragmatic approach. We don't want to unnecessarily break extensions. Adding a proper public API takes time. Cython was particularly aggressive in using any and all API it could, leading underscore or not, if there was even a tiny performance advantage. They have been quite good about updating Cython to adapt to new Python versions but that doesn't help C code generated by Cython and embedded into other extensions. |
This comment was marked as resolved.
This comment was marked as resolved.
I'll delete them, I don't need them anymore. |
PEP 689 clarified the meaning of the leading underscore in names:
As the last point suggests, there is a lot of pre-existing API with a leading underscore, added when the rules were less clear (i.e. the underscore served as a vague warning). It is unfair to users to change or remove this API. (We can do this, as per PEP 387, but that doesn't necessarily mean that we should.)
The text was updated successfully, but these errors were encountered: