-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathhash.py
More file actions
28 lines (24 loc) · 761 Bytes
/
Copy pathhash.py
File metadata and controls
28 lines (24 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class backtrace_element(object):
def __init__(self,backtraces):
self._backtraces = backtraces
def __eq__(self,other):
address1 = self._backtraces
address2 = other._backtraces
if len(address1) != len(address2) :
return False
it1 = address1.__iter__()
it2 = address2.__iter__()
try:
while True:
if it1.next() != it2.next():
return False
except StopIteration as e:
pass
return True
def __hash__(self):
if not hasattr(self, '_cachedHash'):
num = 0
for x in self._backtraces:
num = num ^ x
self._cachedHash = num
return self._cachedHash