-
Notifications
You must be signed in to change notification settings - Fork 51
Stop using _Py_IDENTIFIER() in core CPython. #230
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
Comments
(@ericsnowcurrently Seemingly you're still using the old board.) |
I worry that if you totally get rid of (One example: |
Hmm, that's something I'll have to look into. 🙁 |
There are a few things left to do, but with what I have already done it looks reasonable. So I created https://bugs.python.org/issue46541 and python/cpython#30928. FYI, with the change I've implemented so far (dropping use of Results:Slower (8):
Faster (35):
Benchmark hidden because not significant (15): deltablue, float, hexiom, json_loads, logging_silent, logging_simple, pickle_list, pickle_pure_python, pidigits, raytrace, regex_effbot, regex_v8, sqlite_synth, tornado_http, unpickle_list Geometric mean: 1.01x faster
|
To make this useful for deepfreeze the list of identifiers should be able to merged with the identifiers of deepfreeze, and on runtime the interpreter should intern them. If we are able to get global identifier objects statically allocated then using it within deepfreeze will be much easier and also the identifiers would de-duplicated. |
So are you suggesting that the two scripts (deepfreeze.py and generate_global_objects.py, both in Tools/scripts) should somehow be combined so that the list of identifiers (i.e. pycore_global_strings.h in python/cpython#30928) includes the deep-frozen strings and deepfreeze.py output can reference those? That seems ambitious and intricate, but not impossible. |
Yes, although this will be more complicated it will be worth it for the savings. For this deepfreeze could produce a list of all the identifiers used (using a CLI flag) and dump it in a file and the same can be done for the stdlib modules and the files can be merged to de-duplicate the identifiers, then the global objects header file will be generated will all these strings statically allocated and the deepfreeze could reference these strings just like it does small integers. For interning during python init it can loop through the indentifiers array and since the indentifiers will be unique hence no need to fix any other pointers referencing it. (PyUnicode_InternInPlace modifies the pointer if there is already an interned copy but here there will be no copy already interned). I'll prototype it once python/cpython#30928 lands as it seems it still requires some changes. |
@ericsnowcurrently Do you have an idea about whether and when python/cpython#30928 will land? It is currently a draft and it touches some 80+ files, which makes me wonder about how far out this is. |
I'm planning on dropping the "draft" status later today. I'll need a review but otherwise the main blocker would be any objections anyone has to using the global objects instead of |
What about the objections from people who brought up that these APIs are used by some 3rd party projects? |
I wasn't planning on dropping |
Hmm, the PR summary isn't very clear about that. I'll fix that. |
I posted to python-dev about this: https://mail.python.org/archives/list/[email protected]/thread/DNMZAMB4M6RVR76RDZMUK2WRLI6KAAYS/ |
I merged python/cpython#30928. There are some follow-ups to take care of. See #279. |
While looking into @198, I found that it may be better to get rid of
_Py_IDENTIFIER()
entirely.The text was updated successfully, but these errors were encountered: