Author: Carl Friedrich Bolz <[email protected]>
Branch:
Changeset: r65833:33309a9fd9d0
Date: 2013-07-30 20:55 +0200
http://bitbucket.org/pypy/pypy/changeset/33309a9fd9d0/
Log: 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.
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
@@ -702,11 +702,13 @@
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
@@ -894,7 +896,7 @@
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
@@ -974,6 +976,9 @@
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
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit