[pypy-commit] pypy cpyext-avoid-roundtrip: implement _Py_NewReference directly in C
antocuni
pypy.commits at gmail.com
Fri Oct 13 13:03:11 EDT 2017
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: cpyext-avoid-roundtrip
Changeset: r92745:888c6f93963d
Date: 2017-10-13 18:02 +0100
http://bitbucket.org/pypy/pypy/changeset/888c6f93963d/
Log: implement _Py_NewReference directly in C
diff --git a/pypy/module/cpyext/include/object.h b/pypy/module/cpyext/include/object.h
--- a/pypy/module/cpyext/include/object.h
+++ b/pypy/module/cpyext/include/object.h
@@ -65,6 +65,7 @@
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
+#define _Py_NewReference(ob) (((PyObject *)(ob))->ob_refcnt = 1)
#define _Py_ForgetReference(ob) /* nothing */
#define Py_None (&_Py_NoneStruct)
diff --git a/pypy/module/cpyext/pyobject.py b/pypy/module/cpyext/pyobject.py
--- a/pypy/module/cpyext/pyobject.py
+++ b/pypy/module/cpyext/pyobject.py
@@ -352,14 +352,6 @@
# assert pyobj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY
- at cpython_api([PyObject], lltype.Void)
-def _Py_NewReference(space, obj):
- obj.c_ob_refcnt = 1
- # XXX is it always useful to create the W_Root object here?
- w_type = from_ref(space, rffi.cast(PyObject, obj.c_ob_type))
- assert isinstance(w_type, W_TypeObject)
- get_typedescr(w_type.layout.typedef).realize(space, obj)
-
@init_function
def write_w_marker_deallocating(space):
if we_are_translated():
More information about the pypy-commit
mailing list