Author: Maciej Fijalkowski <[email protected]>
Branch: rdict-experiments
Changeset: r59694:c9a49e752464
Date: 2013-01-04 12:38 +0200
http://bitbucket.org/pypy/pypy/changeset/c9a49e752464/
Log: merge
diff --git a/pypy/rlib/dict.py b/pypy/rlib/dict.py
--- a/pypy/rlib/dict.py
+++ b/pypy/rlib/dict.py
@@ -1,4 +1,3 @@
-
from pypy.rlib.jit_hooks import _cast_to_gcref
from pypy.rlib import rgc
from pypy.rpython.lltypesystem import lltype, llmemory, rclass
@@ -14,6 +13,7 @@
('value', llmemory.GCREF)))
MAIN_TP = lltype.GcArray(lltype.Signed)
+
class Dict(object):
'Space efficient dictionary with fast iteration and cheap resizes.'
@@ -27,7 +27,7 @@
else:
perturb = hashvalue
n = len(self.indices)
- i = perturb & (n-1)
+ i = perturb & (n - 1)
while True:
index = self.indices[i]
if index == FREE:
@@ -37,7 +37,7 @@
elif self.values[index].key == key:
return (index, i)
i = 5 * i + perturb + 1
- i = i & (n-1)
+ i = i & (n - 1)
perturb >>= PERTURB_SHIFT
_lookup._always_inline_ = True
@@ -69,12 +69,12 @@
perturb = -hashvalue
else:
perturb = hashvalue
- i = hashvalue & (n-1)
+ i = hashvalue & (n - 1)
while True:
if self.indices[i] == FREE:
break
i = 5 * i + perturb + 1
- i = i & (n-1)
+ i = i & (n - 1)
perturb >>= PERTURB_SHIFT
self.indices[i] = index
self.filled = self.used
@@ -99,7 +99,6 @@
ptr = lltype.cast_opaque_ptr(rclass.OBJECTPTR, llref)
return cast_base_ptr_to_instance(CLS, ptr)
-
def __setitem__(self, key, value):
hashvalue = key # hash
index, i = self._lookup(key, hashvalue)
@@ -179,7 +178,7 @@
key = self.keylist[-1]
value = self.valuelist[-1]
except IndexError:
- raise KeyError( 'popitem(): dictionary is empty')
+ raise KeyError('popitem(): dictionary is empty')
del self[key]
return key, value
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit