Does the Python “open” function save its content in memory or in a temp file?

后端 未结 6 1529
孤街浪徒
孤街浪徒 2021-01-18 01:42

For the following Python code:

fp = open(\'output.txt\', \'wb\')
# Very big file, writes a lot of lines, n is a very large number
for i in range(1, n):
    f         


        
6条回答
  •  鱼传尺愫
    2021-01-18 02:21

    There will be write buffering in the Linux kernel, but at (ir)regular intervals they will be flushed to disk. Running out of such buffer space should never cause an application-level memory error; the buffers should empty before that happens, pausing the application while doing so.

提交回复
热议问题