def _similarity_score(obj1, obj2, block_cache=None):
 if (block_cache is None):
  block_cache = {}
 if (obj1.id not in block_cache):
  block_cache[obj1.id] = _count_blocks(obj1)
 if (obj2.id not in block_cache):
  block_cache[obj2.id] = _count_blocks(obj2)
 common_bytes = _common_bytes(block_cache[obj1.id], block_cache[obj2.id])
 max_size = max(obj1.raw_length(), obj2.raw_length())
 if (not max_size):
  return _MAX_SCORE
 return int(((float(common_bytes) * _MAX_SCORE) / max_size))

def _similarity_score ( obj1 , obj2 , block_cache = None ) : if ( block_cache is None ) : block_cache = { } if ( obj1 . id not in block_cache ) : block_cache [ obj1 . id ] = _count_blocks ( obj1 ) if ( obj2 . id not in block_cache ) : block_cache [ obj2 . id ] = _count_blocks ( obj2 ) common_bytes = _common_bytes ( block_cache [ obj1 . id ] , block_cache [ obj2 . id ] ) max_size = max ( obj1 . raw_length ( ) , obj2 . raw_length ( ) ) if ( not max_size ) : return _MAX_SCORE return int ( ( ( float ( common_bytes ) * _MAX_SCORE ) / max_size ) )
compute a similarity score for two objects .