-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
Open
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-parsertype-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)
Description
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
:
cpython/Parser/action_helpers.c
Line 1624 in 6416e6e
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
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-parsertype-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)