On Mon, Mar 30, 2020 at 10:00 PM Steven D'Aprano <st...@pearwood.info>
wrote:

> > it’s optimized for a different use case than string building,
>
> It is? That's odd. The whole purpose of StringIO is to build strings.
>
> What use-case do you believe it is optimized for?
>

Let me tell you, since I was there.

StringIO was created in order to fit code designed to a file, where all you
want to do is capture its output and process it further, in the same
process. (Or vice versa for the reading case of course.) IOW its *primary*
feature is that it is a duck type for a file, and that is what it's
optimized for. Also note that it only applies to use cases where the data
does, indeed, fit in the process's memory somewhat easily -- else you
should probably use a temporary file. If the filesystem were fast enough
and temporary files were easier to use we wouldn't have needed it.

-- 
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him **(why is my pronoun here?)*
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________
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/YNMIUHNCVNLD5A2N2C4GOZBT6O7CZEM5/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to