def set(self, pos, value = True):
        if pos < 0:
            raise ValueError('pos must great or equal zero!')

        index, offset = self._get_offset(pos)
        length = len(self.array)
        if index >= length:
            self.array.extend([0] * (index - length + 1))

        if value:
            self.array[index] |= (1 << offset)
        else:
            self.array[index] &= ~(1 << offset)

        self.size = max(self.size, pos + 1)
dataset/ETHPy150Open douban/dpark/dpark/bitindex.py/BitIndex.set/original