This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author methane
Recipients methane
Date 2019-04-29.06:12:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1556518358.69.0.33229526654.issue36748@roundup.psfhosted.org>
In-reply-to
Content
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.

Faster (6):
- write_ascii_32k: 101 ns +- 1 ns -> 73.1 ns +- 0.4 ns: 1.39x faster (-28%)
- write_ascii_8k: 102 ns +- 1 ns -> 73.4 ns +- 0.4 ns: 1.38x faster (-28%)
- write_ascii_linebuffered: 815 ns +- 12 ns -> 731 ns +- 3 ns: 1.12x faster (-10%)
- write_unicode_linebuffered: 840 ns +- 11 ns -> 789 ns +- 15 ns: 1.06x faster (-6%)
- write_unicode_8k: 124 ns +- 1 ns -> 122 ns +- 1 ns: 1.01x faster (-1%)
- write_unicode_32k: 124 ns +- 1 ns -> 122 ns +- 1 ns: 1.01x faster (-1%)
History
Date User Action Args
2019-04-29 06:12:38methanesetrecipients: + methane
2019-04-29 06:12:38methanesetmessageid: <1556518358.69.0.33229526654.issue36748@roundup.psfhosted.org>
2019-04-29 06:12:38methanelinkissue36748 messages
2019-04-29 06:12:38methanecreate