[pypy-commit] pypy default: decided that a cached empty list is too dangerous and that is is better to live

l.diekmann noreply at buildbot.pypy.org
Sat Jan 28 14:01:03 CET 2012


Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
Branch: 
Changeset: r51908:3607ba0bb92d
Date: 2012-01-28 13:08 +0100
http://bitbucket.org/pypy/pypy/changeset/3607ba0bb92d/

Log:	decided that a cached empty list is too dangerous and that is is
	better to live with a sligthly slower empty list creation than with
	unexpected behaviour if we are not careful enough with the getitems
	method

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
@@ -347,8 +347,6 @@
 
     def __init__(self, space):
         ListStrategy.__init__(self, space)
-        # cache an empty list that is used whenever getitems is called (i.e. sorting)
-        self.cached_emptylist_w = []
 
     def init_from_list_w(self, w_list, list_w):
         assert len(list_w) == 0
@@ -376,10 +374,10 @@
     def getslice(self, w_list, start, stop, step, length):
         # will never be called because the empty list case is already caught in
         # getslice__List_ANY_ANY and getitem__List_Slice
-        return W_ListObject(self.space, self.cached_emptylist_w)
+        return W_ListObject(self.space, [])
 
     def getitems(self, w_list):
-        return self.cached_emptylist_w
+        return []
 
     def getitems_copy(self, w_list):
         return []


More information about the pypy-commit mailing list