PEP 756 – [C API] Add PyUnicode_Export() and PyUnicode_Import() C functions

I still think we should provide only stable ABI version of PyUnicode_AsUTF8AndSize(). It might accept option to allow WTF-8 or not.

If we change the internal encoding of unicode in the near future, many technical debt will be remain in PyUnicode_Export() implementation and its users’ code.

I think O(1) guarantee this API provides is not worth enough for its complexity and technical debt. We should make effort to keep stable ABI simple and clean as possible.

Almost all string processing code is O(n). O(n) + O(1) = O(n) + O(n) = O(n).

2 Likes