On Tue, Sep 7, 2021 at 10:00 AM Stefan Behnel
Guido van Rossum schrieb am 07.09.21 um 00:44:
In addition, I just heard from the SC that they've approved the exception. So we will remove these two APIs from 3.11 without deprecation.
Erm, hang on – when I wrote that I'm fine with *changing* them, I wasn't thinking of actually *removing* them. At least not both. PyCode_NewEmpty() isn't a good replacement since it takes low level arguments … char* instead of Python strings. It's good for the simple use case that it was written for (and Cython already uses it for that), but not so great for anything beyond that.
Is the issue that you want to specify a few additional simple arguments, or that you already have unicode objects and you don't want to have them converted back to char * (which will then be converted to new unicode objects by PyCode_NewEmpty)?
What I could try is to create only a single dummy code object and then always call .replace() on it to create new ones. But that seems hackish and requires managing yet another bit of global state across static and generated code parts.
I can't argue with the need for an extra bit of global state, but to me, calling .replace() is not hackish, it's the best way to create new code objects -- it works for older Python versions and will keep working in the future.
I could also switch to _PyCode_New(), though it's not exactly what I would call an attractive option, both for usability reasons and its future API stability. (Cython also still generates C89 code, i.e. no partial struct initialisations.)
That's too bad. With the new struct initializations it's actually more usable and more stable going forward.
Any suggestions?
Stefan
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/B6WFHGVA... Code of Conduct: http://python.org/psf/codeofconduct/
-- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-c...