Python: File IO - disable incremental flash

Kind of opposite this question .

Is there a way to tell Python "Don't burn to disk until I tell you." (by closing or cleaning the file)? I write to a file on the network and prefer to write the whole file at once.

In the meantime, I write to the StringIO buffer, and then write it to disk at the end.

+3
source share
3 answers

No, a look at the python manual does not indicate the ability to set the buffer size to infinity.

Your current solution is basically the same concept.

You could use the idea of ​​Alex, but I would be against it for the following reasons:

  • 2 ^ 31-1 2 . "OverflowError: long int too large to convert to int"
  • :

    a = open("blah.txt", "w", 2 ** 31 - 1)
    for i in xrange(10000): 
        a.write("a")
    

python,

+3

, . , x=open('/tmp/za', 'w', 1000*1000*1000) - , * 100...;-). , , ...

+3

, , .

, , , , , .

, , .

If you want this for other reasons, it may not help.

+1
source

Source: https://habr.com/ru/post/1708377/


All Articles