Yes and no. Data is buffered in various places during the write process: the python file object, the underlying C functions, the operating system, and the disk controller. Even closing the file does not guarantee that all of these buffers are written physically. Only the first two levels are forced to write their buffers to the next level. You can do the same by clearing the file descriptor without closing it. While the power can be turned off at any time, you have to deal with the fact that some data is lost or partially written. Closing a file is important to provide free, limited operating system resources, but this does not apply to your setup.
source share