Commits

Carl Friedrich Bolz committed 33309a9

don't make every strategy intstance have a sizehint field, which needs to be
checked whether it's -1. This saves one guard per normal list creation.

Comments (0)

Files changed (1)

pypy/objspace/std/listobject.py

 find_jmp = jit.JitDriver(greens = [], reds = 'auto', name = 'list.find')
 
 class ListStrategy(object):
-    sizehint = -1
 
     def __init__(self, space):
         self.space = space
 
+    def get_sizehint(self):
+        return -1
+
     def init_from_list_w(self, w_list, list_w):
         raise NotImplementedError
 
         else:
             strategy = self.space.fromcache(ObjectListStrategy)
 
-        storage = strategy.get_empty_storage(self.sizehint)
+        storage = strategy.get_empty_storage(self.get_sizehint())
         w_list.strategy = strategy
         w_list.lstorage = storage
 
         self.sizehint = sizehint
         ListStrategy.__init__(self, space)
 
+    def get_sizehint(self):
+        return self.sizehint
+
     def _resize_hint(self, w_list, hint):
         assert hint >= 0
         self.sizehint = hint