0

In plain Python we can write something like

>>> (0.5).as_integer_ratio()
(1, 2)

Is there a way to get this result through Python C API? The only thing I see is an implementation.

Azat Ibrakov
  • 9,998
  • 9
  • 38
  • 50
  • 1
    You can call any Python callable with the `PyObject_Call*` set of functions. I assume you know this and are looking for a more direct way to access it? (which I don't think there is) – DavidW May 31 '21 at 13:49
  • @DavidW: thanks, that could work, but I was hoping that there is some sort of utility that does exactly that by mutating pointers instead of creating intermediate `tuple` object – Azat Ibrakov May 31 '21 at 14:52
  • 1
    Not built into Python I think. The implementation looks well-commented and fairly simple so if I were you I'd just copy and modify to get your desired inputs/outputs. – DavidW May 31 '21 at 15:47

0 Answers0