Debian Codegraph @

pypy/module/cpyext/src/complexobject.c

raw symbols SCIP
1
2 #include "Python.h"
3
4 Py_complex
5 PyComplex_AsCComplex(PyObject *obj)
6 {
7 Py_complex result;
8 if (_PyComplex_AsCComplex(obj, &result) < 0) {
9 result.real = -1.;
10 result.imag = 0.;
11 }
12 return result;
13 }
14
15 PyObject *
16 PyComplex_FromCComplex(Py_complex c)
17 {
18 return _PyComplex_FromCComplex(&c);
19 }
20
21 int
22 PyIndex_Check(PyObject *obj)
23 {
24 /* Taken from cpython/Include/internal/pycore_abstract.h */
25 if (obj == NULL)
26 return 0;
27 PyNumberMethods *tp_as_number = Py_TYPE(obj)->tp_as_number;
28 return (tp_as_number != NULL && tp_as_number->nb_index != NULL);
29 }
30
31 int
32 PyNumber_Check(PyObject *obj)
33 {
34 if (obj == NULL)
35 return 0;
36 PyNumberMethods *nb = Py_TYPE(obj)->tp_as_number;
37 return nb && (nb->nb_index || nb->nb_int || nb->nb_float || PyComplex_Check(obj));
38 }
39
40