])
def _handle_simple_function_getattr(self, node, pos_args):
- # not really a builtin *type*, but worth optimising anyway
args = pos_args.args
if len(args) == 2:
node = ExprNodes.PythonCapiCallNode(
"expected 2 or 3, found %d" % len(args))
return node
+ Pyx_Type_func_type = PyrexTypes.CFuncType(
+ Builtin.type_type, [
+ PyrexTypes.CFuncTypeArg("object", PyrexTypes.py_object_type, None)
+ ])
+
+ def _handle_simple_function_type(self, node, pos_args):
+ args = pos_args.args
+ if len(args) != 1:
+ return node
+ node = ExprNodes.PythonCapiCallNode(
+ node.pos, "__Pyx_Type", self.Pyx_Type_func_type,
+ args = args,
+ is_temp = node.is_temp,
+ utility_code = pytype_utility_code,
+ )
+ return node
+
### methods of builtin types
PyObject_Append_func_type = PyrexTypes.CFuncType(
)
+pytype_utility_code = UtilityCode(
+proto = """
+static INLINE PyObject* __Pyx_Type(PyObject* o) {
+ PyObject* type = (PyObject*) Py_TYPE(o);
+ Py_INCREF(type);
+ return type;
+}
+"""
+)
+
+
class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
"""Calculate the result of constant expressions to store it in
``expr_node.constant_result``, and replace trivial cases by their