code: def _inplace_logical_helper(self, bs, f):
          
          # Give the two bitstrings the same offset (modulo 8)
          self_byteoffset, self_bitoffset = divmod(self._offset, 8)
          bs_byteoffset, bs_bitoffset = divmod(bs._offset, 8)
          if bs_bitoffset != self_bitoffset:
              if not self_bitoffset:
                  bs._datastore = offsetcopy(bs._datastore, 0)
              else:
                  self._datastore = offsetcopy(self._datastore, bs_bitoffset)
          a = self._datastore.rawbytes
          b = bs._datastore.rawbytes
          for i in xrange(len(a)):
              a[i] = f(a[i + self_byteoffset], b[i + bs_byteoffset])
          return self
docs: Helper function containing most of the __ior__, __iand__, __ixor__ code.