From 35c536a37234939beadf736fb0299ecf841f7a3f Mon Sep 17 00:00:00 2001 From: Fabio Costa Date: Wed, 25 Jun 2014 09:56:45 +0100 Subject: [PATCH] Update fingerprint.py --- dejavu/fingerprint.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dejavu/fingerprint.py b/dejavu/fingerprint.py index 45ee59c..fa0df79 100755 --- a/dejavu/fingerprint.py +++ b/dejavu/fingerprint.py @@ -97,6 +97,12 @@ def generate_hashes(peaks, fan_value=DEFAULT_FAN_VALUE): """ fingerprinted = set() # to avoid rehashing same pairs + fingerprinted = set() # to avoid rehashing same pairs + + from operator import itemgetter + peaks.sort(key=itemgetter(1)) + + _len = 0 for i in range(len(peaks)): for j in range(1, fan_value): if (i + j) < len(peaks) and not (i, i + j) in fingerprinted: @@ -112,6 +118,8 @@ def generate_hashes(peaks, fan_value=DEFAULT_FAN_VALUE): h = hashlib.sha1( "%s|%s|%s" % (str(freq1), str(freq2), str(t_delta))) yield (h.hexdigest()[0:20], t1) + _len += 1 # ensure we don't repeat hashing fingerprinted.add((i, i + j)) + print "hashes: %s", _len