How to find the cpython source code file for a specific 3rd party (NumPy for instance) API?

亡梦爱人 提交于 2020-01-06 04:30:06

问题


This question comes from this post.

I am digging out the underlying logic for numpy.linalg.eig.

w, v = np.linalg.eig(C.T*C)
v
matrix([[-0.9486833 , -0.31622777],
        [ 0.31622777, -0.9486833 ]])

the implementation of np.linalg.eig

w, vt = _umath_linalg.eig(a, signature=signature, extobj=extobj)

is linked here, which links to _umath_linalg.py

_umath_linalg.py corresponds to <python3.6>/site-packages/numpy/linalg/_umath_linalg.cpython-36m-darwin.so

I searched lots of keywords comes from _umath_linalg.eig on the cpython source code gh repo and got nothing related.

in this case, how to find the cpython source code file for _umath_linalg.cpython-36m-darwin.so or _umath_linalg.eig?


回答1:


Exactly where the different libraries live outside of PyPi isn't a common location across all modules, but usually they're somewhere on github. In this case you're not looking for the source of cpython itself, but of the linalg module inside numpy. Asking a search engine for numpy linalg github will give you the location.

You can also use pip download to download the source code of any module available on PyPi to a directory of your choice. This can be useful for fetching a specific version and to see what has been uploaded to PyPi:

pip download numpy -d <directory>


来源:https://stackoverflow.com/questions/56781686/how-to-find-the-cpython-source-code-file-for-a-specific-3rd-party-numpy-for-ins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!