Skip to content Skip to sidebar Skip to footer

How Optimize Bk-tree

I'm implementing a BK-Tree in Cython. For one million items, the search time is too long! It's ~30 seconds :( Here is my Cython code: # -*- coding: UTF-8 -*- from itertools impo

Solution 1:

You can save a lot of memory (and thus swapping and/or cache flushing) by representing your "256-bit hash" in 256 bits (32 bytes) instead of 256 or 512 bytes.

Python pseudocode:

num_bits_set = (0, 1, 1, 2, 1, etc etc, 7, 8)
assertlen(num_bits_set) == 256defham_diff(a, b):
    h = 0for p, q inzip(a, b):
        h += num_bits_set[ord(p) ^ ord(q)]
    return h

Post a Comment for "How Optimize Bk-tree"