binary io/buffered io classes bufferedwriter when writing to this objectdata is normally placed into an internal buffer the buffer will be written out to the underlying rawiobase object under various conditionsincludingwhen the buffer gets too small for all pending datawhen flush(is calledwhen the bufferedwriter object is closed or destroyed bufferedrandom buffered interface to random access streams it supports seek(and tell(functionality bufferedrwpair buffered / object combining two unidirectional rawiobase objects one readablethe other writeable--into single bidirectional endpoint each of the above classes wrap lower level byte oriented stream class such as the io fileio classfor examplef io fileio('data dat'br io bufferedreader(fprint(br read()this allows data in the form of bytes to be read from the file 'data datyou can of course also read data from different sourcesuch as an in memory bytesio objectbinary_stream_from_file io bufferedreader(io bytesio( 'starship png')bytes binary_stream_from_file read( print(bytesin this example the data is read from the bytesio object by the bufferedreader the read(method is then used to read the first bytesthe output isnote the 'bin front of both the string 'starship pngand the result 'starthis indicates that the string literal should become bytes literal in python bytes literals are always prefixed with 'bor ' 'they produce an instance of the bytes type instead of the str type they may only contain ascii characters the operations supported by buffered streams includefor readingpeek(nreturn up to bytes of data without advancing the stream pointer the number of bytes returned may be less or more than requested depending on the amount of data available read(nreturn bytes of data as bytesif is not supplied (or is negativethe read all available data readl(nread up to bytes of data using single call on the raw data stream