Commit 2675db3f authored by Stefan Behnel's avatar Stefan Behnel

move tp_new() utility code into ObjectHandling.c

parent a46b2a59
...@@ -2179,9 +2179,9 @@ class OptimizeBuiltinCalls(Visitor.MethodDispatcherTransform): ...@@ -2179,9 +2179,9 @@ class OptimizeBuiltinCalls(Visitor.MethodDispatcherTransform):
return ExprNodes.PythonCapiCallNode( return ExprNodes.PythonCapiCallNode(
node.pos, "__Pyx_tp_new", self.Pyx_tp_new_func_type, node.pos, "__Pyx_tp_new", self.Pyx_tp_new_func_type,
args = [type_arg], args=[type_arg],
utility_code = tpnew_utility_code, utility_code=UtilityCode.load_cached('tp_new', 'ObjectHandling.c'),
is_temp = node.is_temp is_temp=node.is_temp
) )
### methods of builtin types ### methods of builtin types
...@@ -2905,16 +2905,6 @@ bytes_tailmatch_utility_code = UtilityCode.load_cached('bytes_tailmatch', 'Strin ...@@ -2905,16 +2905,6 @@ bytes_tailmatch_utility_code = UtilityCode.load_cached('bytes_tailmatch', 'Strin
str_tailmatch_utility_code = UtilityCode.load_cached('str_tailmatch', 'StringTools.c') str_tailmatch_utility_code = UtilityCode.load_cached('str_tailmatch', 'StringTools.c')
tpnew_utility_code = UtilityCode(
proto = """
static CYTHON_INLINE PyObject* __Pyx_tp_new(PyObject* type_obj) {
return (PyObject*) (((PyTypeObject*)(type_obj))->tp_new(
(PyTypeObject*)(type_obj), %(TUPLE)s, NULL));
}
""" % {'TUPLE' : Naming.empty_tuple}
)
class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations): class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
"""Calculate the result of constant expressions to store it in """Calculate the result of constant expressions to store it in
``expr_node.constant_result``, and replace trivial cases by their ``expr_node.constant_result``, and replace trivial cases by their
......
...@@ -650,3 +650,12 @@ bad: ...@@ -650,3 +650,12 @@ bad:
__Pyx_PyObject_CallMethodTuple(obj, name, PyTuple_Pack(1, arg1)) __Pyx_PyObject_CallMethodTuple(obj, name, PyTuple_Pack(1, arg1))
#define __Pyx_PyObject_CallMethod0(obj, name) \ #define __Pyx_PyObject_CallMethod0(obj, name) \
__Pyx_PyObject_CallMethodTuple(obj, name, (Py_INCREF($empty_tuple), $empty_tuple)) __Pyx_PyObject_CallMethodTuple(obj, name, (Py_INCREF($empty_tuple), $empty_tuple))
/////////////// tp_new.proto ///////////////
//@substitute: naming
static CYTHON_INLINE PyObject* __Pyx_tp_new(PyObject* type_obj) {
return (PyObject*) (((PyTypeObject*)(type_obj))->tp_new(
(PyTypeObject*)(type_obj), $empty_tuple, NULL));
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment