Looking good at math module.c , I got the following:
static PyObject * math_frexp(PyObject *self, PyObject *arg) { int i; double x = PyFloat_AsDouble(arg); if (x == -1.0 && PyErr_Occurred()) return NULL; if (Py_IS_NAN(x) || Py_IS_INFINITY(x) || !x) { i = 0; } else { PyFPE_START_PROTECT("in math_frexp", return 0); x = frexp(x, &i); PyFPE_END_PROTECT(x); } return Py_BuildValue("(di)", x, i); }
If you look at the code, it really uses float ( PyFloat_AsDouble )
Same for exp ,
static PyObject * math_factorial(PyObject *self, PyObject *arg) { long x; PyObject *result, *odd_part, *two_valuation; if (PyFloat_Check(arg)) { PyObject *lx; double dx = PyFloat_AS_DOUBLE((PyFloatObject *)arg); if (!(Py_IS_FINITE(dx) && dx == floor(dx))) { PyErr_SetString(PyExc_ValueError, "factorial() only accepts integral values"); return NULL; } lx = PyLong_FromDouble(dx); if (lx == NULL) return NULL; x = PyLong_AsLong(lx); Py_DECREF(lx); .........................................................
enginefree
source share