7
When it is necessary to work with strings very large it is normal to see approaches that seek to optimize the process in some way. Of the approaches I have seen are using:
io.StringIO
orio.BytesIO
tempfile.TemporaryFile
tempfile.NamedTemporaryFile
tempfile.SpooledTemporaryFile
The four forms are objects file-like and can be used with a context manager.
with io.StringIO() as stream:
...
with tempfile.TemporaryFile() as stream:
...
with tempfile.NamedTemporaryFile as stream:
...
with tempfile.SpooledTemporaryFile as stream:
...
What is the difference between using each of these solutions? There are other ways?
Yes, it was very useful. Just to clarify, the idea of the question was precisely to have this content, even if summarized, in Portuguese. I already knew the differences, but now we have an initial reference to use reference :D
– Woss
Great way to boost the community !
– Absolver