Kind of the opposite of this question.
Is there a way to tell Python "Do not write to disk until I tell you to." (by closing or flushing the file)? I'm writing to a file on the network, and would rather write the entire file at once.
In the meantime, I'm writing to a StringIO buffer, and then writing that to the disk at the end.
No, a glance at the python manual does not indicate an option to set the buffer size to infinity.
Your current solution is basically the same concept.
You could use Alex's idea, but I would hazard against it for the following reasons:
It doesn't seem to work:
a = open("blah.txt", "w", 2 ** 31 - 1)
for i in xrange(10000):
a.write("a")
Open up the file without closing python, and you will see the text
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With