changeset 39094:07b6d6538483

module: a faster hash computation
author Dmitry Selyutin <ghostmansd@gmail.com>
date Fri, 12 Jan 2018 23:09:16 +0300
parents fe5b2fdcb19c
children aa4a38ae88c7
files pygnulib/module.py
diffstat 1 files changed, 3 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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):