code: def count_range(self, txn, from_key, to_key):
          
          key_from = struct.pack('>H', self._slot) + self._serialize_key(from_key)
          to_key = struct.pack('>H', self._slot) + self._serialize_key(to_key)
  
          cnt = 0
          cursor = txn._txn.cursor()
          has_more = cursor.set_range(key_from)
          while has_more:
              if cursor.key() >= to_key:
                  break
              cnt += 1
              has_more = cursor.next()
  
          return cnt
docs: Counter number of records in the perstistent map with keys
          within the given range.
  
          :param txn: The transaction in which to run.
          :type txn: :class:`zlmdb.Transaction`
  
          :param from_key: Count records starting and including from this key.
          :type from_key: object
  
          :param to_key: End counting records before this key.
          :type to_key: object
  
          :returns: The number of records.
          :rtype: int