operating system services bufferedwriter(raw [buffer_size [max_buffer_size]] class for buffered binary writing on raw file specified in raw buffer_size specifies the number of bytes that can be saved in the buffer before data is flushed to the underlying / stream the default value is default_buffer_size max_buffer_size specifies the maximum buffer size to use for storing output data that is being written to non-blocking stream and defaults to twice the value of buffer_size this value is larger to allow for continued writing while the previous buffer contents are written to the / stream by the operating system an instance of bufferedwriter supports the following operationsmethod description flush(writes all bytes stored in the buffer to the underlying / stream raises blockingioerror exception if the file is in nonblocking mode and the operation would block ( if the stream can' accept any new data at the momentwrites the bytes in bytes to the / stream and returns the number of bytes actually written if the underlying stream is nonblockinga blockingioerror exception is raised if write operation would block write(bytesbufferedrwpair(readerwriter [buffer_size [max_buffer_size]] class for buffered binary reading and writing on pair of raw / streams reader is raw file that supports readingand writing is raw file that supports writing these files may be differentwhich may be useful for certain kinds of communication involving pipes and sockets the buffer size parameters have the same meaning as for bufferedwriter an instance of bufferedrwpair supports all of the operations for bufferedreader and bufferedwriter bufferedrandom(raw [buffer_size [max_buffer_size]] class for buffered binary reading and writing on raw / stream that supports random access ( seekingraw must be raw file that supports both readwriteand seek operations the buffer size parameters have the same meaning as for bufferedwriter an instance of bufferedrandom supports all of the operations for bufferedreader and bufferedwriter bytesio([bytes]an in-memory file that implements the functionality of buffered / stream bytes is byte string that specifies the initial contents of the file an instance of bytesio supports all of the operations of bufferedreader and bufferedwriter objects in additiona method getvalue(can be used to return the current contents of the file as byte string as with fileio objectsall the file objects in this section should not be used with line-oriented data such as text although it' not quite as bad due to bufferingthe resulting performance is still quite poor ( more than times slower than reading lines with files created using the python built-in open(functionalsobecause of internal bufferingyou need to take care to manage flush(operations when writing for exampleif you use seek(to move the file pointer to new locationyou should first use flush(to flush any previously written data (if anyf lib fl ff