# HG changeset patch # User Dmitry Selyutin # Date 1515787756 -10800 # Node ID 07b6d653848309932a615aab1364ec66c5fd76b2 # Parent fe5b2fdcb19ccfb9fbb2e4b3f0dbb0d3ccd8fe89 module: a faster hash computation diff -r fe5b2fdcb19c -r 07b6d6538483 pygnulib/module.py --- a/pygnulib/module.py Fri Jan 12 23:05:54 2018 +0300 +++ b/pygnulib/module.py Fri Jan 12 23:09:16 2018 +0300 @@ -6,8 +6,9 @@ import ast as _ast import codecs as _codecs +import collections as _collections import hashlib as _hashlib -import collections as _collections +import json as _json import os as _os import re as _re @@ -78,10 +79,7 @@ def __hash__(self): - result = hash(self.__name) - for key in sorted(self.keys()): - result ^= hash(tuple(self[key])) - return result + return hash(self.__name) ^ _json.dumps(self.__table, sort_keys=True) def __getitem__(self, key):