where is math_sin defined?

Chris Angelico rosuav at gmail.com
Sun Feb 10 11:43:04 EST 2019


On Mon, Feb 11, 2019 at 3:37 AM Barry Scott <barry at barrys-emacs.org> wrote:
>
> 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:
>

Effective, if a little tedious.

My technique was to first confirm that there was nothing saying
"math_sin" anywhere in the repo (trust but verify - doesn't hurt to do
a quick "git grep"), then to search mathmodule.c for "sin(", since
searching for "sin" on its own gave way too many hits. That led me to
the definition of sinpi(), then to asin() and sin(), both being
defined using the FUNC1 template.

ChrisA


More information about the Python-list mailing list