python的api怎么找_如何查找特定第三方(例如NumPy)API的cpython源代码文件?

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 /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?

解决方案

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值