def get(self, n):
        assert n <= self.byteSz, 'caller responsibility to ensure enough bytes'

        if (n == self.byteSz and len(self._dq) == 1 and
            isinstance(self._dq[0], bytes)):
            # Fast-path: if the deque has one element of the right
            # size *and* type (fragmentation can result in 'buffer'
            # objects pushed back on the deque) return it and avoid a
            # copy.
            self.byteSz = 0
            return self._dq.popleft()

        out = bytearray(n)
        remaining = n
        while remaining > 0:
            part = self._dq.popleft()
            delta = remaining - len(part)
            offset = n - remaining

            if delta == 0:
                out[offset:] = part
                remaining = 0
            elif delta > 0:
                out[offset:] = part
                remaining = delta
            elif 0 < delta:
                cleave = len(part) + delta
                out[offset:] = buffer(part, 0, cleave)
                self._dq.appendleft(buffer(part, cleave))
                remaining = 0
            else:
                assert False

        self.byteSz -= n

        assert len(out) == n
        return bytes(out)
dataset/ETHPy150Open wal-e/wal-e/wal_e/pipebuf.py/ByteDeque.get/swapped operands of `<`