Victor Stinner

Results 756 comments of Victor Stinner

> I'd prefer a PyUnicodeWriter_WriteStr that calls PyObject_Str() (which should be cheap for actual PyUnicode objects). It would pair well with the proposed future additions, PyUnicodeWriter_WriteRepr & PyUnicodeWriter_WriteAscii :) As...

> PyUnicodeWriter_WriteSubstring can still take PyUnicode only. Right, it raises TypeError if the argument is not a Python str objet. Same than `PyUnicodeWriter_WriteString()`.

> IMO, the best name is PyUnicodeWriter_WriteStr, except it's a bit ambiguous -- people might expect it to call str(). I don't see why users would expect that. I don't...

My issue is that my proposed API is based on an existing implementation which is around for 12 years. It's uneasy for me to think "ouf of the box" to...

Update: * Rename `PyUnicodeWriter_Free()` to `PyUnicodeWriter_Discard()`. * Rename `PyUnicodeWriter_WriteString()` to `PyUnicodeWriter_WriteStr()`: the function now calls `str(obj)`. * Add `PyUnicodeWriter_WriteRepr()`: call `repr(obj)`.

I opened an issue for the C API Working Group: https://github.com/capi-workgroup/decisions/issues/27

> I opened an issue for the C API Working Group: https://github.com/capi-workgroup/decisions/issues/27 API approved. I merged my PR.

I ran again https://github.com/python/cpython/issues/119182#issuecomment-2119488134 benchmark: PyUnicodeWriter is **1.8x faster** than string concatenation. ``` $ env/bin/python bench.py ..................... bench_concat: Mean +- std dev: 1.13 us +- 0.02 us ..................... bench_writer: Mean...

This issue has many people involved, many comments, I don't think that it should be closed.

Recent discussion: https://github.com/zopefoundation/zodbpickle/pull/64#issuecomment-1025732450