Author: Maciej Fijalkowski <fij...@gmail.com> Branch: virtual-arguments Changeset: r56086:b804a064343c Date: 2012-07-15 19:33 +0200 http://bitbucket.org/pypy/pypy/changeset/b804a064343c/
Log: shift dict_unrolling_heuristics to dictmultiobject.py diff --git a/pypy/objspace/std/dictmultiobject.py b/pypy/objspace/std/dictmultiobject.py --- a/pypy/objspace/std/dictmultiobject.py +++ b/pypy/objspace/std/dictmultiobject.py @@ -29,6 +29,18 @@ space.is_w(w_lookup_type, space.w_float) ) + +DICT_CUTOFF = 5 + +@specialize.call_location() +def w_dict_unrolling_heuristic(w_dct): + """ In which cases iterating over dict items can be unrolled. + Note that w_dct is an instance of W_DictMultiObject, not necesarilly + an actual dict + """ + return jit.isvirtual(w_dct) or (jit.isconstant(w_dct) and + w_dct.length() <= DICT_CUTOFF) + class W_DictMultiObject(W_Object): from pypy.objspace.std.dicttype import dict_typedef as typedef @@ -512,7 +524,7 @@ return self.space.newlist_str(self.listview_str(w_dict)) @jit.look_inside_iff(lambda self, w_dict: - jit.w_dict_unrolling_heuristic(w_dict)) + w_dict_unrolling_heuristic(w_dict)) def view_as_kwargs(self, w_dict): d = self.unerase(w_dict.dstorage) l = len(d) diff --git a/pypy/rlib/jit.py b/pypy/rlib/jit.py --- a/pypy/rlib/jit.py +++ b/pypy/rlib/jit.py @@ -214,17 +214,6 @@ """ return isvirtual(lst) or (isconstant(size) and size <= LIST_CUTOFF) -DICT_CUTOFF = 5 - -@specialize.call_location() -def w_dict_unrolling_heuristic(w_dct): - """ In which cases iterating over dict items can be unrolled. - Note that w_dct is an instance of W_DictMultiObject, not necesarilly - an actual dict - """ - return isvirtual(w_dct) or (isconstant(w_dct) and - w_dct.length() <= DICT_CUTOFF) - class Entry(ExtRegistryEntry): _about_ = hint _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit