[pypy-svn] r5338 - pypy/trunk/src/pypy/objspace/std
arigo at codespeak.net
arigo at codespeak.net
Sat Jun 26 01:46:33 CEST 2004
Author: arigo
Date: Sat Jun 26 01:46:33 2004
New Revision: 5338
Modified:
pypy/trunk/src/pypy/objspace/std/dictobject.py
Log:
Previous revision buggy! Using min() to means "at least"... It's max() that
should be used for that purpose...
Re-enabled the runaway check, and made sure that it cannot fire except in
buggy cases.
Modified: pypy/trunk/src/pypy/objspace/std/dictobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/dictobject.py (original)
+++ pypy/trunk/src/pypy/objspace/std/dictobject.py Sat Jun 26 01:46:33 2004
@@ -20,7 +20,7 @@
w_self.used = 0
w_self.data = []
- w_self.resize(min(len(list_pairs_w)*2, 8))
+ w_self.resize(len(list_pairs_w)*2)
for w_k, w_v in list_pairs_w:
w_self.insert(w_self.hash(w_k), w_k, w_v)
@@ -41,7 +41,7 @@
cell[2] = w_value
def resize(self, minused):
- newsize = 1
+ newsize = 4
while newsize < minused:
newsize *= 2
od = self.data
@@ -73,9 +73,16 @@
freeslot = None
perturb = lookup_hash
- c = 0
+ if __debug__:
+ c = len(self.data) + 99
while 1:
- c += 1
+ if __debug__:
+ c -= 1
+ if not c:
+ import sys, pdb
+ print >> sys.stderr, 'dict lookup lost in infinite loop'
+ pdb.set_trace()
+
i = (i << 2) + i + perturb + 1
entry = self.data[i%len(self.data)]
if entry[1] is None:
More information about the Pypy-commit
mailing list