def update(self, b):  # pylint: disable=method-hidden,invalid-name
        """Compress data given in b, returning compressed result either from this function or writing to fp). Note:
           sometimes output might be zero length (if being buffered by lz4).
           Raises Lz4FramedNoDataError if input is of zero length."""
        with self.__lock:
            output = compress_update(self.__ctx, b)
            if self.__write:
                self.__write(self.__header)
                self.__header = None
                self.__write(output)
                self.update = self.__updateNextWrite
            else:
                header = self.__header
                self.__header = None
                self.update = self.__updateNextReturn
                return header + output