Skip to content
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

PyUnicode_FromUnicode is deprecated. #288

Closed
methane opened this issue Jun 14, 2020 · 3 comments
Closed

PyUnicode_FromUnicode is deprecated. #288

methane opened this issue Jun 14, 2020 · 3 comments

Comments

@methane
Copy link

methane commented Jun 14, 2020

PyUnicode_FromUnicode is deprecated since Python 3.3.
We are planning to remove it in Python 3.11.

./apsw-3.9.2-r1/src/apsw.c:1053:      unires=PyUnicode_FromUnicode(NULL, PyUnicode_GET_SIZE(value)+2);
./apsw-3.9.2-r1/src/apsw.c:1120:            unires=PyUnicode_FromUnicode(NULL, buflen*2+3),
./apsw-3.9.2-r1/src/pyutil.c:246:          PyObject *res=PyUnicode_FromUnicode(NULL, size);
rogerbinns added a commit that referenced this issue Jun 15, 2020
@rogerbinns
Copy link
Owner

I am not removing the two other occurrences until forced by the API actually going away (ie compile errors). I have spent enough time on this already.

The logical and documented thing to do would be to use PyUnicode_New but that is documented as being non-resizeable. Resizing is needed in the code, figuring out some other path through the API functions failed.

rogerbinns added a commit that referenced this issue Jun 15, 2020
This reverts commit 54fb6de.

Since the other uses are staying, this can too

Refs #288
@methane
Copy link
Author

methane commented Jun 16, 2020

PyUnicode_DecodeUTF8 has a fast path [1] for ASCII string, and creating unicode from Py_UNICODE is slow since Python 3.3.
So please don't use this "optimization" for Python 3.

[1] https://github.com/python/cpython/blob/e0bec69854ff17b1a6db9bc01db8c002761bb7a8/Objects/unicodeobject.c#L4993-L5001

rogerbinns added a commit that referenced this issue Jun 16, 2020
That is most text when using SQLite.  perf showed a small consistent
improvement in speedtest

Refs #288
@rogerbinns
Copy link
Owner

For clarity, APSW now only uses current APIs with no deprecated API usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants