textio uses list of textio for internal buffering. There are two inefficiency:
When textio is line buffered and all written strings are line (it's very common), list object is allocated and freed.
We convert texts into bytes, and call b''.join(list_of_bytes). But when texts are ASCII and codecs are ASCII-compat, we can skip temporary bytes objects.
Attached patch is benchmark for buffered and line buffered write.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: