Does Python Automatically Flush Its Buffer When Calling Seek And/or Read Operations Following A Write?
Let's say I write the following python code: file = open('test.txt','w+') file.write('hi') file.seek(0) file.read() The second line tells Python that I want to write 'hi' to file.
Solution 1:
For specifically CPython, for buffered IO seek
calls the _io__Buffered_seek_impl
which is guaranteed to flush if and only if the whence argument is set to SEEK_END
(2
)
read
with zero arguments calls _bufferedreader_read_all
through _io__Buffered_read_impl
, which does flush.
Post a Comment for "Does Python Automatically Flush Its Buffer When Calling Seek And/or Read Operations Following A Write?"