Author: Carl Friedrich Bolz <cfb...@gmx.de> Branch: remove-objspace-options Changeset: r83833:48959a7aa4db Date: 2016-04-22 11:37 +0300 http://bitbucket.org/pypy/pypy/changeset/48959a7aa4db/
Log: remove the withmapdict option and turn it on by default there is still some cleanup needed in get_unique_interplevel_subclass diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py --- a/pypy/config/pypyoption.py +++ b/pypy/config/pypyoption.py @@ -218,10 +218,6 @@ default=False, requires=[("objspace.honor__builtins__", False)]), - BoolOption("withmapdict", - "make instances really small but slow without the JIT", - default=False), - BoolOption("withliststrategies", "enable optimized ways to store lists of primitives ", default=True), @@ -277,14 +273,12 @@ config.objspace.std.suggest(withprebuiltint=True) config.objspace.std.suggest(withliststrategies=True) config.objspace.std.suggest(sharesmallstr=True) - config.objspace.std.suggest(withmapdict=True) if not IS_64_BITS: config.objspace.std.suggest(withsmalllong=True) # extra optimizations with the JIT if level == 'jit': config.objspace.std.suggest(withcelldict=True) - config.objspace.std.suggest(withmapdict=True) def enable_allworkingmodules(config): diff --git a/pypy/config/test/test_pypyoption.py b/pypy/config/test/test_pypyoption.py --- a/pypy/config/test/test_pypyoption.py +++ b/pypy/config/test/test_pypyoption.py @@ -11,12 +11,6 @@ assert conf.objspace.usemodules.gc - conf.objspace.std.withmapdict = True - assert conf.objspace.std.withtypeversion - conf = get_pypy_config() - conf.objspace.std.withtypeversion = False - py.test.raises(ConfigError, "conf.objspace.std.withmapdict = True") - def test_conflicting_gcrootfinder(): conf = get_pypy_config() conf.translation.gc = "boehm" @@ -47,10 +41,10 @@ def test_set_pypy_opt_level(): conf = get_pypy_config() set_pypy_opt_level(conf, '2') - assert conf.objspace.std.getattributeshortcut + assert conf.objspace.std.intshortcut conf = get_pypy_config() set_pypy_opt_level(conf, '0') - assert not conf.objspace.std.getattributeshortcut + assert not conf.objspace.std.intshortcut def test_check_documentation(): def check_file_exists(fn): diff --git a/pypy/doc/config/objspace.std.withmapdict.txt b/pypy/doc/config/objspace.std.withmapdict.txt deleted file mode 100644 --- a/pypy/doc/config/objspace.std.withmapdict.txt +++ /dev/null @@ -1,5 +0,0 @@ -Enable the new version of "sharing dictionaries". - -See the section in `Standard Interpreter Optimizations`_ for more details. - -.. _`Standard Interpreter Optimizations`: ../interpreter-optimizations.html#sharing-dicts diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py --- a/pypy/interpreter/pycode.py +++ b/pypy/interpreter/pycode.py @@ -114,6 +114,7 @@ e.write_unraisable(self.space, "new_code_hook()") def _initialize(self): + from pypy.objspace.std.mapdict import init_mapdict_cache if self.co_cellvars: argcount = self.co_argcount assert argcount >= 0 # annotator hint @@ -149,9 +150,7 @@ self._compute_flatcall() - if self.space.config.objspace.std.withmapdict: - from pypy.objspace.std.mapdict import init_mapdict_cache - init_mapdict_cache(self) + init_mapdict_cache(self) def _init_ready(self): "This is a hook for the vmprof module, which overrides this method." diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -951,8 +951,7 @@ def LOAD_ATTR(self, nameindex, next_instr): "obj.attributename" w_obj = self.popvalue() - if (self.space.config.objspace.std.withmapdict - and not jit.we_are_jitted()): + if not jit.we_are_jitted(): from pypy.objspace.std.mapdict import LOAD_ATTR_caching w_value = LOAD_ATTR_caching(self.getcode(), w_obj, nameindex) else: diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py --- a/pypy/interpreter/typedef.py +++ b/pypy/interpreter/typedef.py @@ -160,7 +160,7 @@ typedef = cls.typedef if wants_dict and typedef.hasdict: wants_dict = False - if config.objspace.std.withmapdict and not typedef.hasdict: + if not typedef.hasdict: # mapdict only works if the type does not already have a dict if wants_del: parentcls = get_unique_interplevel_subclass(config, cls, True, True, @@ -226,7 +226,7 @@ value = func_with_new_name(value, value.func_name) body[key] = value - if (config.objspace.std.withmapdict and "dict" in features): + if "dict" in features: from pypy.objspace.std.mapdict import BaseMapdictObject, ObjectMixin add(BaseMapdictObject) add(ObjectMixin) @@ -300,24 +300,6 @@ return self.slots_w[index] add(Proto) - if "dict" in features: - base_user_setup = supercls.user_setup.im_func - if "user_setup" in body: - base_user_setup = body["user_setup"] - class Proto(object): - def getdict(self, space): - return self.w__dict__ - - def setdict(self, space, w_dict): - self.w__dict__ = check_new_dictionary(space, w_dict) - - def user_setup(self, space, w_subtype): - self.w__dict__ = space.newdict( - instance=True) - base_user_setup(self, space, w_subtype) - - add(Proto) - subcls = type(name, (supercls,), body) _allusersubcls_cache[subcls] = True return subcls diff --git a/pypy/module/__builtin__/test/test_builtin.py b/pypy/module/__builtin__/test/test_builtin.py --- a/pypy/module/__builtin__/test/test_builtin.py +++ b/pypy/module/__builtin__/test/test_builtin.py @@ -748,10 +748,6 @@ raises(TypeError, delattr, A(), 42) -class AppTestGetattrWithGetAttributeShortcut(AppTestGetattr): - spaceconfig = {"objspace.std.getattributeshortcut": True} - - class TestInternal: def test_execfile(self, space): fn = str(udir.join('test_execfile')) diff --git a/pypy/module/__builtin__/test/test_classobj.py b/pypy/module/__builtin__/test/test_classobj.py --- a/pypy/module/__builtin__/test/test_classobj.py +++ b/pypy/module/__builtin__/test/test_classobj.py @@ -1118,8 +1118,7 @@ assert getattr(c, u"x") == 1 -class AppTestOldStyleMapDict(AppTestOldstyle): - spaceconfig = {"objspace.std.withmapdict": True} +class AppTestOldStyleMapDict: def setup_class(cls): if cls.runappdirect: diff --git a/pypy/module/__pypy__/__init__.py b/pypy/module/__pypy__/__init__.py --- a/pypy/module/__pypy__/__init__.py +++ b/pypy/module/__pypy__/__init__.py @@ -110,9 +110,8 @@ 'interp_magic.method_cache_counter') self.extra_interpdef('reset_method_cache_counter', 'interp_magic.reset_method_cache_counter') - if self.space.config.objspace.std.withmapdict: - self.extra_interpdef('mapdict_cache_counter', - 'interp_magic.mapdict_cache_counter') + self.extra_interpdef('mapdict_cache_counter', + 'interp_magic.mapdict_cache_counter') PYC_MAGIC = get_pyc_magic(self.space) self.extra_interpdef('PYC_MAGIC', 'space.wrap(%d)' % PYC_MAGIC) try: diff --git a/pypy/module/__pypy__/interp_magic.py b/pypy/module/__pypy__/interp_magic.py --- a/pypy/module/__pypy__/interp_magic.py +++ b/pypy/module/__pypy__/interp_magic.py @@ -37,17 +37,15 @@ cache = space.fromcache(MethodCache) cache.misses = {} cache.hits = {} - if space.config.objspace.std.withmapdict: - cache = space.fromcache(MapAttrCache) - cache.misses = {} - cache.hits = {} + cache = space.fromcache(MapAttrCache) + cache.misses = {} + cache.hits = {} @unwrap_spec(name=str) def mapdict_cache_counter(space, name): """Return a tuple (index_cache_hits, index_cache_misses) for lookups in the mapdict cache with the given attribute name.""" assert space.config.objspace.std.withmethodcachecounter - assert space.config.objspace.std.withmapdict cache = space.fromcache(MapAttrCache) return space.newtuple([space.newint(cache.hits.get(name, 0)), space.newint(cache.misses.get(name, 0))]) diff --git a/pypy/module/gc/interp_gc.py b/pypy/module/gc/interp_gc.py --- a/pypy/module/gc/interp_gc.py +++ b/pypy/module/gc/interp_gc.py @@ -6,14 +6,14 @@ @unwrap_spec(generation=int) def collect(space, generation=0): "Run a full collection. The optional argument is ignored." - # First clear the method cache. See test_gc for an example of why. + # First clear the method and the map cache. + # See test_gc for an example of why. from pypy.objspace.std.typeobject import MethodCache + from pypy.objspace.std.mapdict import MapAttrCache cache = space.fromcache(MethodCache) cache.clear() - if space.config.objspace.std.withmapdict: - from pypy.objspace.std.mapdict import MapAttrCache - cache = space.fromcache(MapAttrCache) - cache.clear() + cache = space.fromcache(MapAttrCache) + cache.clear() rgc.collect() return space.wrap(0) diff --git a/pypy/module/gc/test/test_gc.py b/pypy/module/gc/test/test_gc.py --- a/pypy/module/gc/test/test_gc.py +++ b/pypy/module/gc/test/test_gc.py @@ -106,7 +106,6 @@ class AppTestGcMethodCache(object): - spaceconfig = {"objspace.std.withmethodcache": True} def test_clear_method_cache(self): import gc, weakref @@ -127,10 +126,6 @@ assert r() is None -class AppTestGcMapDictIndexCache(AppTestGcMethodCache): - spaceconfig = {"objspace.std.withmethodcache": True, - "objspace.std.withmapdict": True} - def test_clear_index_cache(self): import gc, weakref rlist = [] diff --git a/pypy/objspace/std/callmethod.py b/pypy/objspace/std/callmethod.py --- a/pypy/objspace/std/callmethod.py +++ b/pypy/objspace/std/callmethod.py @@ -33,7 +33,7 @@ space = f.space w_obj = f.popvalue() - if space.config.objspace.std.withmapdict and not jit.we_are_jitted(): + if not jit.we_are_jitted(): # mapdict has an extra-fast version of this function if LOOKUP_METHOD_mapdict(f, nameindex, w_obj): return @@ -59,8 +59,7 @@ # nothing in the instance f.pushvalue(w_descr) f.pushvalue(w_obj) - if (space.config.objspace.std.withmapdict and - not jit.we_are_jitted()): + if not jit.we_are_jitted(): # let mapdict cache stuff LOOKUP_METHOD_mapdict_fill_cache_method( space, f.getcode(), name, nameindex, w_obj, w_type) 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 @@ -66,7 +66,7 @@ w_obj = space.allocate_instance(W_ModuleDictObject, space.w_dict) W_ModuleDictObject.__init__(w_obj, space, strategy, storage) return w_obj - elif space.config.objspace.std.withmapdict and instance: + elif instance: from pypy.objspace.std.mapdict import MapDictStrategy strategy = space.fromcache(MapDictStrategy) elif instance or strdict or module: diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py --- a/pypy/objspace/std/mapdict.py +++ b/pypy/objspace/std/mapdict.py @@ -583,7 +583,6 @@ pass # mainly for tests def get_subclass_of_correct_size(space, cls, w_type): - assert space.config.objspace.std.withmapdict map = w_type.terminator classes = memo_get_subclass_of_correct_size(space, cls) if SUBCLASSES_MIN_FIELDS == SUBCLASSES_MAX_FIELDS: diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py --- a/pypy/objspace/std/objspace.py +++ b/pypy/objspace/std/objspace.py @@ -356,8 +356,7 @@ if cls.typedef.applevel_subclasses_base is not None: cls = cls.typedef.applevel_subclasses_base # - if (self.config.objspace.std.withmapdict and cls is W_ObjectObject - and not w_subtype.needsdel): + if cls is W_ObjectObject and not w_subtype.needsdel: from pypy.objspace.std.mapdict import get_subclass_of_correct_size subcls = get_subclass_of_correct_size(self, cls, w_subtype) else: diff --git a/pypy/objspace/std/test/test_dictmultiobject.py b/pypy/objspace/std/test/test_dictmultiobject.py --- a/pypy/objspace/std/test/test_dictmultiobject.py +++ b/pypy/objspace/std/test/test_dictmultiobject.py @@ -1114,7 +1114,6 @@ class objspace: class std: withcelldict = False - withmapdict = False methodcachesizeexp = 11 withmethodcachecounter = False diff --git a/pypy/objspace/std/test/test_mapdict.py b/pypy/objspace/std/test/test_mapdict.py --- a/pypy/objspace/std/test/test_mapdict.py +++ b/pypy/objspace/std/test/test_mapdict.py @@ -5,7 +5,6 @@ class objspace: class std: withcelldict = False - withmapdict = True methodcachesizeexp = 11 withmethodcachecounter = False @@ -645,7 +644,6 @@ # XXX write more class AppTestWithMapDict(object): - spaceconfig = {"objspace.std.withmapdict": True} def test_simple(self): class A(object): @@ -862,8 +860,7 @@ class AppTestWithMapDictAndCounters(object): - spaceconfig = {"objspace.std.withmapdict": True, - "objspace.std.withmethodcachecounter": True} + spaceconfig = {"objspace.std.withmethodcachecounter": True} def setup_class(cls): from pypy.interpreter import gateway @@ -1206,8 +1203,7 @@ assert got == 'd' class AppTestGlobalCaching(AppTestWithMapDict): - spaceconfig = {"objspace.std.withmethodcachecounter": True, - "objspace.std.withmapdict": True} + spaceconfig = {"objspace.std.withmethodcachecounter": True} def test_mix_classes(self): import __pypy__ @@ -1264,8 +1260,7 @@ assert 0, "failed: got %r" % ([got[1] for got in seen],) class TestDictSubclassShortcutBug(object): - spaceconfig = {"objspace.std.withmapdict": True, - "objspace.std.withmethodcachecounter": True} + spaceconfig = {"objspace.std.withmethodcachecounter": True} def test_bug(self): w_dict = self.space.appexec([], """(): diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py --- a/pypy/objspace/std/typeobject.py +++ b/pypy/objspace/std/typeobject.py @@ -176,12 +176,11 @@ # dict_w of any of the types in the mro changes, or if the mro # itself changes w_self._version_tag = VersionTag() - if space.config.objspace.std.withmapdict: - from pypy.objspace.std.mapdict import DictTerminator, NoDictTerminator - if w_self.hasdict: - w_self.terminator = DictTerminator(space, w_self) - else: - w_self.terminator = NoDictTerminator(space, w_self) + from pypy.objspace.std.mapdict import DictTerminator, NoDictTerminator + if w_self.hasdict: + w_self.terminator = DictTerminator(space, w_self) + else: + w_self.terminator = NoDictTerminator(space, w_self) def __repr__(self): "NOT_RPYTHON" _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit