You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
these two functions were quickly added by me because I needed them for ujson. They return char * to match CPython's signature, but I think they should return const char* instead.
The reason why CPython's returns char* is this note in the docs:
[...] The data must not be modified in any way, unless the object was just created using PyBytes_FromStringAndSize(NULL, size)
But I don't think we want to support this use case. Instead, we should introduce StringBuilders (see #181 ).
Moreover, this will be consistent with e.g. [H]PyUnicode_AsUTF8: it used to return char*, but since CPython 3.7 it returns const char*
Another question is whether we want to keep the AS_STRING version at all, and all the similar UPPERCASE macros. Ideally not, but on CPython they might be slightly faster, so we need proper benchmarks to make an proper decision.
The text was updated successfully, but these errors were encountered:
We should also document how long the returned memory is valid (perhaps only as long as the handle?) and add checks to debug mode that it is not written to and that it is not accessed after the handle is closed (or whatever lifetime we pick).
Currently we have:
these two functions were quickly added by me because I needed them for ujson. They return
char *
to match CPython's signature, but I think they should returnconst char*
instead.The reason why CPython's returns
char*
is this note in the docs:But I don't think we want to support this use case. Instead, we should introduce StringBuilders (see #181 ).
Moreover, this will be consistent with e.g.
[H]PyUnicode_AsUTF8
: it used to returnchar*
, but since CPython 3.7 it returnsconst char*
Another question is whether we want to keep the
AS_STRING
version at all, and all the similar UPPERCASE macros. Ideally not, but on CPython they might be slightly faster, so we need proper benchmarks to make an proper decision.The text was updated successfully, but these errors were encountered: