code: def fromfile(cls, f, n=-1):
          
          headerlen = calcsize(cls.FILE_FMT)
  
          if 0 < n < headerlen:
              raise ValueError('n too small!')
  
          filter = cls(1)  # Bogus instantiation, we will `_setup'.
          filter._setup(*unpack(cls.FILE_FMT, f.read(headerlen)))
          filter.bitarray = bitarray.bitarray(endian='little')
          if n > 0:
              (filter.bitarray.frombytes(f.read(n-headerlen)) if is_string_io(f)
               else filter.bitarray.fromfile(f, n - headerlen))
          else:
              (filter.bitarray.frombytes(f.read()) if is_string_io(f)
               else filter.bitarray.fromfile(f))
          if filter.num_bits != filter.bitarray.length() and \
                 (filter.num_bits + (8 - filter.num_bits % 8)
                  != filter.bitarray.length()):
              raise ValueError('Bit length mismatch!')
  
          return filter
docs: Read a bloom filter from file-object `f' serialized with
          ``BloomFilter.tofile''. If `n' > 0 read only so many bytes.