[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

where is math_sin defined?

> On 10 Feb 2019, at 16:43, Chris Angelico <rosuav at gmail.com> wrote:
> 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.

Tedious? Its fast and accurate only took 20s and got the answer right first time.

I had spent a few minutes reading and greping the code and my grep fu found to many false positives.


> 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
> -- 
> https://mail.python.org/mailman/listinfo/python-list