Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimized hamming distance computation #230

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

taras-sereda
Copy link

This PR optimizes computation of hamming distance by XORing two integers and counting bits. On folder with 4000 images allows to compute all pair-wise distances 30x faster then current implementation.

Attention: bit_count() was added in python 3.10
for earlier python version an equivalent helper function will serve the same purpose:

def big_count(n):
    count = 0
    while n:
        count += n & 1
        n >>= 1
    return count

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant