-
Notifications
You must be signed in to change notification settings - Fork 1
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
Macro to hide deprecated functions #24
Comments
Victor proposed fine-grained flags like |
Is there any value in specifying a version, and not just having a flag to totally hide anything that would trigger a deprecation warning in the current headers (if we did those reliably in C)? My initial thought was that of course we should allow a version, but I'd prefer it to be semantically more like the limited API one (so set So maybe just |
I imagine users will set this when they start a new project, and then they won't update it. In a few years when we declare there's now a slightly better way of doing something, they won't be bothered with warnings – but new projects won't see the old API. If we need to be more forceful – for API that's unsafe, dangerous in most uses, or blocking development – we have regular deprecation warnings. |
Ah I see, so we hide any definitions that were soft-deprecated before the version, and hide any warnings for soft deprecations after the version. In that case, maybe something like |
Rust's edition is similar but different – it changes behaviour. In my sprint slides I used epoch ("an event or a time marked by an event that begins a new period or development" or "an instant of time or a date selected as a point of reference").
Soft deprecations are already only mentioned in docs. (And picked up by linters, hopefully, soon.) |
"Epoch" is already used in packaging as an optional first part of a version number, which leads some to consider the "3" in 3.x to be the epoch.
What value would there be in setting it to a later version that the earliest that you support?
Then are we suppressing warnings for hard deprecations with this? |
You'd do that if you want to use new features, but don't want to rewrite all of your code.
No. We are hiding (not exposing) deprecated and soft-deprecated API. |
I think I might need a worked example to better illustrate how this would work over the period of a few CPython releases.
We've already said that the limited API needs to be compiled with the earliest version you want to support, so I guess we're not talking about that here. In the regular API, we require compiling with the headers from the version that build is going to support. So if I'm compiling with the 3.13 headers, but set the flag to 3.14, what does that achieve? We don't have metadata in the 3.13 headers relating to 3.14 deprecations, soft or otherwise. Are we going to start backporting it? If not (and I hope not), what value is there? If you want to use 3.14 features, you need to drop 3.13 (or do your own detection). At that point, your minimum version matches the flag again. I don't understand how it helps to hide 3.14 deprecations when building for 3.13, unless we're going to backport them. |
ExampleI'm building a new extension for 3.20+. Some time laterI've written the extension for 3.20. |
Thanks. Having two independent variables makes sense. So with that, setting |
I proposed a concrete PEP to implement this idea: PEP 743 "Add Py_COMPAT_API_VERSION to the Python C API". You can join the discussion at: https://discuss.python.org/t/pep-743-add-py-compat-api-version-to-the-python-c-api/48243 |
(from capi-workgroup/problems#54)
New meta-API idea:
Define a macro like
Py_NO_LEGACY=0x30c0000
to hide definitions of all API that's deprecated and soft-deprecated in that version.This is strictly optional, meant for people who tend to like linters.
Users can to set it for new projects to e.g. hide the unnecessary definitions from editor autocompletion.
If and when we add "modern" alternatives to everything, it can make it easier to review things like refcounting.
What's a good name for it?
The text was updated successfully, but these errors were encountered: