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

Hashing an EPM #73

Open
cthoyt opened this issue Sep 11, 2023 · 0 comments
Open

Hashing an EPM #73

cthoyt opened this issue Sep 11, 2023 · 0 comments

Comments

@cthoyt
Copy link
Member

cthoyt commented Sep 11, 2023

It might be worth having a way to hash an EPM so they can be quickly indexed / compared for equality

def get_hash(self) -> str:
    import hashlib
    from operator import attrgetter

    h = hashlib.md5()
    for record in sorted(self.records, key=attrgetter("prefix")):
        h.update(record.prefix.encode("utf8"))
        h.update(record.uri_prefix.encode("utf8"))
        for s in itt.chain(sorted(record.prefix_synonyms), sorted(record.uri_prefix_synonyms)):
            h.update(s.encode("utf8"))
    return h.hexdigest()
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

No branches or pull requests

1 participant