Does Python interpreter load all the file to RAM when it is opened for writing?
with open('file.txt' 'w') as file:
file.write(some_content)
No. As per the docs, open() wraps a system call and returns a file object, the file contents are not loaded into RAM (unless you invoke, E.G., readlines()).
wmode truncates the file anyway, so there are no contents to load into memory. Also noteworthy:opentakes a third, optional argument, which lets you control buffer size when reading.