'Write a byte string to the file.
Returns the number of uncompressed bytes written, which is
always len(data). Note that due to buffering, the file on disk
may not reflect the data written until close() is called.'

def write(self, data):

    with self._lock:
        self._check_can_write()
        if isinstance(data, memoryview):
            data = data.tobytes()
        compressed = self._compressor.compress(data)
        self._fp.write(compressed)
        self._pos += len(data)
        return len(data)
