
Hi, Lamburg. Thank you for quick response.
We can't just remove access to one half of a codec (the decoding part) without at least providing an alternative for C extensions to use.
Py_UNICODE can be removed from the API, but only if there are alternative APIs which C extensions can use to the same effect.
Given PEP 393, this would be APIs which use wchar_t instead of Py_UNICODE.
Decoding part is implemented as `const char *` -> `PyObject*` (Unicode object). I think this is reasonable since `const char *` is perfect to abstract the encoded string, In case of encoding part, `wchar_t *` is not perfect abstraction for (decoded) unicode string. Converting from Unicode object into `wchar_t *` is not zero-cost. I think `PyObject *` (Unicode object) -> `PyObject *` (bytes object) looks better signature than `wchar_t *` -> `Pyobject *` (bytes object) because for encoders. * Unicode object is more important than `wchar_t *` in Python. * All PyUnicode_EncodeXXX APIs are implemented with PyUnicode_FromWideChar. For example, we have these private encode APIs: * PyObject* _PyUnicode_AsAsciiString(PyObject *unicode, const char *errors) * PyObject* _PyUnicode_AsLatin1String(PyObject *unicode, const char *errors) * PyObject* _PyUnicode_AsUTF8String(PyObject *unicode, const char *errors) * PyObject* _PyUnicode_EncodeUTF16(PyObject *unicode, const char *errors, int byteorder) ... So how about making them public, instead of undeprecate Py_UNICODE* encode APIs? 1. Add PyUnicode_AsXXXBytes public APIs in Python 3.10. Current private APIs can become macro (e.g. #define _PyUnicode_AsAsciiString PyUnicode_AsAsciiBytes), or deprecated static inline function. 2. Remove Py_UNICODE* encode APIs in Python 3.12. Regards, -- Inada Naoki <songofacandy@gmail.com>