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
Replace _Py_IDENTIFIER() with statically initialized objects. #90699
Comments
This would involve the following:
As part of this, we would also do the following:
(Note that there are several hundred uses of Pros:
Cons:
Note that with a basic partial implementation (GH-30928) I'm seeing a 1% improvement in performance (see faster-cpython/ideas#230). |
## Background ##
The solution involved using a static variable defined, using Over the last decade a number of changes were made, including recent changes to make the identifiers per-interpreter and to use a centralized cache. [1] afe55bb |
This change is going to break projects in the wild. Yes, people use the _Py_IDENTIFIER(), _PyUnicode_FromId() and other "Id" variant of many functions in 3rd party projects. Is it possible to keep runtime initialization if this API is used by 3rd party code? |
If necessary, we can keep _Py_IDENTIFIER() (and the functions). Regardless, we can stop using it internally. |
FYI, I've posted to python-dev for feedback before proceeding: https://mail.python.org/archives/list/python-dev@python.org/thread/DNMZAMB4M6RVR76RDZMUK2WRLI6KAAYS/ |
Sorry if off topic, but I noticed that CPython doesn't deprecate macros in code, while with gcc/clang it's possible to show compiler warnings for them using some pragma magic: $ gcc a.c
a.c: In function 'main':
a.c:29:13: warning: Deprecated pre-processor symbol
29 | PySomethingDeprecated (0);
| ^~~~~~~~~~~~~~~~~~
a.c:30:13: warning: Deprecated pre-processor symbol: replace with "SomethingCompletelyDifferent"
30 | PySomethingDeprecated2 (42);
| ^~~~~~~~~~~~~~~~~~~~ Here is how glib implements this for example: https://gist.github.com/lazka/4749c74249a3918a059d944040aca4a3 Maybe that makes getting rid of them easier in the long run? |
On Fri, Feb 11, 2022 at 1:36 AM Christoph Reiter <report@bugs.python.org> wrote:
That's a good question. We do have Py_DEPRECATED() (in FWIW, here are other explanations of how to deprecate macros: |
With core code sorted out, stdlib and 3rd party extension modules are left to sort out. I see the following possibilities:
|
(from #31376 (comment)) [corona10]
I think it's fine to use the one issue. There are only 26 modules with |
Great! and thank you for all your efforts :) |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: