Author: Armin Rigo <[email protected]>
Branch: stmgc-c8-dictstrategy
Changeset: r80979:357192d019e3
Date: 2015-11-26 16:36 +0000
http://bitbucket.org/pypy/pypy/changeset/357192d019e3/

Log:    Yay, seems to have unblocked the situation for objspace/std/stmdict.

diff --git a/pypy/module/pypystm/stmdict.py b/pypy/module/pypystm/stmdict.py
--- a/pypy/module/pypystm/stmdict.py
+++ b/pypy/module/pypystm/stmdict.py
@@ -131,6 +131,15 @@
     if pop_from_entry(h, space, w_key) is None:
         space.raise_key_error(w_key)
 
+def get_length(space, h):
+    array, count = h.list()
+    total_length_times_two = 0
+    for i in range(count):
+        subarray = lltype.cast_opaque_ptr(PARRAY, array[i].object)
+        assert subarray
+        total_length_times_two += len(subarray)
+    return total_length_times_two >> 1
+
 
 class W_STMDict(W_Root):
 
@@ -187,15 +196,6 @@
         return w_default
 
 
-    def get_length(self):
-        array, count = self.h.list()
-        total_length_times_two = 0
-        for i in range(count):
-            subarray = lltype.cast_opaque_ptr(PARRAY, array[i].object)
-            assert subarray
-            total_length_times_two += len(subarray)
-        return total_length_times_two >> 1
-
     def get_keys_values_w(self, offset):
         array, count = self.h.list()
         result_list_w = []
@@ -226,7 +226,7 @@
         return result_list_w
 
     def len_w(self, space):
-        return space.wrap(self.get_length())
+        return space.wrap(get_length(space, self.h))
 
     def keys_w(self, space):
         return space.newlist(self.get_keys_values_w(offset=0))
diff --git a/pypy/objspace/std/stmdict.py b/pypy/objspace/std/stmdict.py
--- a/pypy/objspace/std/stmdict.py
+++ b/pypy/objspace/std/stmdict.py
@@ -12,6 +12,10 @@
     def get_empty_storage(self):
         return self.erase(stmdict.create())
 
+    def length(self, w_dict):
+        h = self.unerase(w_dict.dstorage)
+        return stmdict.get_length(self.space, h)
+
     def setitem(self, w_dict, w_key, w_value):
         h = self.unerase(w_dict.dstorage)
         stmdict.setitem(self.space, h, w_key, w_value)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to