where is math_sin defined?

Barry Scott barry at barrys-emacs.org
Sun Feb 10 10:53:32 EST 2019


On Sunday, 10 February 2019 15:15:32 GMT Jon Ribbens wrote:
> As an aside, how is 'math.sin' actually implemented? mathmodule.c
> refers to the function 'math_sin' but that name is not defined
> anywhere in the Python source code. I'm a bit mystified as to how
> CPython manages to compile!

I used gdb to find it:

Breakpoint 1, math_sin (self=<module at remote 0x7fffea716098>, args=0) at /
usr/src/debug/python3-3.7.2-4.fc29.x86_64/Modules/mathmodule.c:1176
1176    FUNC1(sin, sin, 0,
(gdb) l
1171          "remainder($module, x, y, /)\n--\n\n"
1172          "Difference between x and the closest integer multiple of y.
\n\n"
1173          "Return x - n*y where n*y is the closest integer multiple of y.
\n"
1174          "In the case where x is exactly halfway between two multiples 
of\n"
1175          "y, the nearest even value of n is used. The result is always 
exact.")
1176    FUNC1(sin, sin, 0,
1177          "sin($module, x, /)\n--\n\n"
1178          "Return the sine of x (measured in radians).")
1179    FUNC1(sinh, sinh, 1,
1180          "sinh($module, x, /)\n--\n\n"
(gdb) 

Barry





More information about the Python-list mailing list