summaryrefslogtreecommitdiffstats
path: root/Objects/clinic
diff options
context:
space:
mode:
authorLisa Roach <lisaroach14@gmail.com>2018-09-14 06:56:23 (GMT)
committerRaymond Hettinger <rhettinger@users.noreply.github.com>2018-09-14 06:56:23 (GMT)
commit5ac704306f4b81ae3f28d8742408d3214b145e8a (patch)
tree34a39f0216d918b679367a84e05f2326aef70a7c /Objects/clinic
parent83df50ea5757816c7338d27f21fd18b1e79206f7 (diff)
downloadcpython-5ac704306f4b81ae3f28d8742408d3214b145e8a.zip
cpython-5ac704306f4b81ae3f28d8742408d3214b145e8a.tar.gz
cpython-5ac704306f4b81ae3f28d8742408d3214b145e8a.tar.bz2
bpo-33073: Adding as_integer_ratio to ints. (GH-8750)
Diffstat (limited to 'Objects/clinic')
-rw-r--r--Objects/clinic/longobject.c.h30
1 files changed, 29 insertions, 1 deletions
diff --git a/Objects/clinic/longobject.c.h b/Objects/clinic/longobject.c.h
index 14f5515..0e70fe5 100644
--- a/Objects/clinic/longobject.c.h
+++ b/Objects/clinic/longobject.c.h
@@ -118,6 +118,34 @@ int_bit_length(PyObject *self, PyObject *Py_UNUSED(ignored))
return int_bit_length_impl(self);
}
+PyDoc_STRVAR(int_as_integer_ratio__doc__,
+"as_integer_ratio($self, /)\n"
+"--\n"
+"\n"
+"Return integer ratio.\n"
+"\n"
+"Return a pair of integers, whose ratio is exactly equal to the original int\n"
+"and with a positive denominator.\n"
+"\n"
+">>> (10).as_integer_ratio()\n"
+"(10, 1)\n"
+">>> (-10).as_integer_ratio()\n"
+"(-10, 1)\n"
+">>> (0).as_integer_ratio()\n"
+"(0, 1)");
+
+#define INT_AS_INTEGER_RATIO_METHODDEF \
+ {"as_integer_ratio", (PyCFunction)int_as_integer_ratio, METH_NOARGS, int_as_integer_ratio__doc__},
+
+static PyObject *
+int_as_integer_ratio_impl(PyObject *self);
+
+static PyObject *
+int_as_integer_ratio(PyObject *self, PyObject *Py_UNUSED(ignored))
+{
+ return int_as_integer_ratio_impl(self);
+}
+
PyDoc_STRVAR(int_to_bytes__doc__,
"to_bytes($self, /, length, byteorder, *, signed=False)\n"
"--\n"
@@ -211,4 +239,4 @@ int_from_bytes(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyOb
exit:
return return_value;
}
-/*[clinic end generated code: output=fd64beb83bd16df3 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=6d5e92d7dc803751 input=a9049054013a1b77]*/