Author: Armin Rigo <[email protected]>
Branch: set-strategies
Changeset: r53993:c49198dda243
Date: 2012-03-26 16:29 +0200
http://bitbucket.org/pypy/pypy/changeset/c49198dda243/

Log:    Performance improvement.

diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -139,12 +139,13 @@
         new erased object as storage"""
         self.strategy.init_from_list_w(self, list_w)
 
-    def clear(self):
-        """Make the listobject empty."""
-        if self.space.config.objspace.std.withliststrategies:
-            strategy = self.space.fromcache(EmptyListStrategy)
+    def clear(self, space):
+        """Initializes (or overrides) the listobject as empty."""
+        self.space = space
+        if space.config.objspace.std.withliststrategies:
+            strategy = space.fromcache(EmptyListStrategy)
         else:
-            strategy = self.space.fromcache(ObjectListStrategy)
+            strategy = space.fromcache(ObjectListStrategy)
         self.strategy = strategy
         strategy.clear(self)
 
@@ -1067,7 +1068,7 @@
     # this is on the silly side
     w_iterable, = __args__.parse_obj(
             None, 'list', init_signature, init_defaults)
-    w_list.clear()
+    w_list.clear(space)
     if w_iterable is not None:
         if isinstance(w_iterable, W_ListObject):
             w_iterable.copy_into(w_list)
diff --git a/pypy/objspace/std/listtype.py b/pypy/objspace/std/listtype.py
--- a/pypy/objspace/std/listtype.py
+++ b/pypy/objspace/std/listtype.py
@@ -43,7 +43,7 @@
 def descr__new__(space, w_listtype, __args__):
     from pypy.objspace.std.listobject import W_ListObject
     w_obj = space.allocate_instance(W_ListObject, w_listtype)
-    W_ListObject.__init__(w_obj, space, [])
+    w_obj.clear(space)
     return w_obj
 
 # ____________________________________________________________
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to