[pypy-svn] r40098 - in pypy/dist/pypy: config doc/config objspace/std
cfbolz at codespeak.net
cfbolz at codespeak.net
Thu Mar 8 21:50:16 CET 2007
Author: cfbolz
Date: Thu Mar 8 21:50:13 2007
New Revision: 40098
Added:
pypy/dist/pypy/doc/config/objspace.std.methodcachesizeexp.txt
- copied unchanged from r40094, pypy/dist/pypy/doc/config/objspace.std.methodcachesize.txt
Removed:
pypy/dist/pypy/doc/config/objspace.std.methodcachesize.txt
Modified:
pypy/dist/pypy/config/pypyoption.py
pypy/dist/pypy/objspace/std/objspace.py
pypy/dist/pypy/objspace/std/typeobject.py
Log:
use a mask instead of a modulo for the method cache index determination
Modified: pypy/dist/pypy/config/pypyoption.py
==============================================================================
--- pypy/dist/pypy/config/pypyoption.py (original)
+++ pypy/dist/pypy/config/pypyoption.py Thu Mar 8 21:50:13 2007
@@ -195,9 +195,9 @@
"for testing purposes only.",
default=False,
requires=[("objspace.std.withmethodcache", True)]),
- IntOption("methodcachesize",
- "size of the method cache (should be a power of 2)",
- default=2048),
+ IntOption("methodcachesizeexp",
+ "2 ** methodcachesizeexp is the size of the of the method cache ",
+ default=11),
BoolOption("withmultilist",
"use lists optimized for flexibility",
default=False,
Modified: pypy/dist/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/dist/pypy/objspace/std/objspace.py (original)
+++ pypy/dist/pypy/objspace/std/objspace.py Thu Mar 8 21:50:13 2007
@@ -299,7 +299,7 @@
ec = ObjSpace.createexecutioncontext(self)
ec._py_repr = self.newdict()
if self.config.objspace.std.withmethodcache:
- SIZE = self.config.objspace.std.methodcachesize
+ SIZE = 2 ** self.config.objspace.std.methodcachesizeexp
ec.method_cache_versions = [None] * SIZE
ec.method_cache_names = [None] * SIZE
ec.method_cache_lookup_where = [(None, None)] * SIZE
Modified: pypy/dist/pypy/objspace/std/typeobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/typeobject.py (original)
+++ pypy/dist/pypy/objspace/std/typeobject.py Thu Mar 8 21:50:13 2007
@@ -320,8 +320,8 @@
if version_tag is None:
tup = w_self._lookup_where(name)
return tup
- SIZE = space.config.objspace.std.methodcachesize
- method_hash = (id(version_tag) ^ position_hash ^ hash(name)) % SIZE
+ MASK = 2 ** space.config.objspace.std.methodcachesizeexp - 1
+ method_hash = (id(version_tag) ^ position_hash ^ hash(name)) & MASK
cached_version_tag = ec.method_cache_versions[method_hash]
if cached_version_tag is version_tag:
cached_name = ec.method_cache_names[method_hash]
More information about the Pypy-commit
mailing list