Skip to content

Use PyBytesWriter API in io.RawIOBase.readall #140135

@maurycy

Description

@maurycy

Feature or enhancement

Proposal:

There's new PyBytesWriter() API:

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

With its PyList_Append

r = PyList_Append(chunks, data);

and PyBytes_Join:

https://github.com/python/cpython/blob/2ca3c85054b231505c5e6f5f3209eb5f63942dce/Modules/_io/iobase.c#L1010C14-L1010C26

the io.RawIOBase.readall looks like the ideal candidate for PyBytesWriter.

Notably, io.RawIOBase is used internally across many modules:

https://github.com/search?q=repo%3Apython%2Fcpython+io.RawIOBase+path%3A%2F%5ELib%5C%2F%2F&type=code

and some even call readall explicitly sometimes:

return self.readall()

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions