On Tue, Mar 31, 2020 at 03:01:51PM +1100, Steven D'Aprano wrote: > > nor the fastest way > > It's pretty close though. > > On my test, accumulating 500,000 strings into a list versus a StringIO > buffer, then building a string, took 27.5 versus 31.6 ms. Using a string > took 36.4 ms. So it's faster than the optimized string concat, and > within arm's reach of list+join.
I re-ran the test with a single non-ASCII character added to the very end, '\U0001D400'. Both the list and the StringIO versions slowed down by about the same amount of time (approx 4ms) so the difference between them remained the same in absolute terms but shrank marginally in relative terms. YMMV. -- Steven _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/2G64USGBXSNXTOEQRNQV6IVFZCNMXGG6/ Code of Conduct: http://python.org/psf/codeofconduct/