[pypy-svn] r73608 - pypy/branch/cpython-extension/pypy/module/cpyext
xoraxax at codespeak.net
xoraxax at codespeak.net
Sat Apr 10 12:21:46 CEST 2010
Author: xoraxax
Date: Sat Apr 10 12:21:45 2010
New Revision: 73608
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/state.py
pypy/branch/cpython-extension/pypy/module/cpyext/typeobject.py
Log:
Only allocate new_method_def once.
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/state.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/state.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/state.py Sat Apr 10 12:21:45 2010
@@ -11,6 +11,7 @@
self.reset()
def reset(self):
+ from pypy.module.cpyext.modsupport import PyMethodDef
self.py_objects_w2r = {} # { w_obj -> raw PyObject }
self.py_objects_r2w = {} # { addr of raw PyObject -> w_obj }
self.borrow_mapping = {} # { addr of container -> { addr of containee -> None } }
@@ -19,6 +20,7 @@
self.last_container = 0 # addr of last container
self.exc_type = None
self.exc_value = None
+ self.new_method_def = lltype.nullptr(PyMethodDef)
def _freeze_(self):
assert not self.borrowed_objects and not self.borrow_mapping
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/typeobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/typeobject.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/typeobject.py Sat Apr 10 12:21:45 2010
@@ -165,11 +165,15 @@
@specialize.memo()
def get_new_method_def(space):
+ state = space.fromcache(State)
+ if state.new_method_def:
+ return state.new_method_def
from pypy.module.cpyext.modsupport import PyMethodDef
ptr = lltype.malloc(PyMethodDef, flavor="raw", zero=True)
ptr.c_ml_name = rffi.str2charp("__new__")
rffi.setintfield(ptr, 'c_ml_flags', METH_VARARGS | METH_KEYWORDS)
ptr.c_ml_doc = rffi.str2charp("T.__new__(S, ...) -> a new object with type S, a subtype of T")
+ state.new_method_def = ptr
return ptr
def setup_new_method_def(space):
More information about the Pypy-commit
mailing list