maurycy · GitHub

Feature or enhancement

Proposal:

There's new PyBytesWriter() API:

There's an ongoing effort of introducing it in various places:

action_helpers.c's _build_concatenated_bytes, which is a part of the PEG parser, is a great candidate for using PyBytesWriter API with its PyBytes_Concat:

PyBytes_Concat(&res, elem->v.Constant.value);

This seems to be quadratic time complexity, while using a modern API and just a single copy is possible!

Inspired by gh-140139, I found this while grepping for PyBytes_Concat and PyUnicodeWriter. My hypothesis is that for many there's a missing PyBytesWriter yang.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

Read the original on github.com ↗