如何查找特定第三方(例如NumPy)API的cpython源代码文件? [英] How to find the cpython source code file for a specific 3rd party (NumPy for instance) API?

查看:307
本文介绍了如何查找特定第三方(例如NumPy)API的cpython源代码文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题来自此帖子

我正在挖掘 numpy.linalg.eig 的基本逻辑。

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 ]])

np.linalg.eig的实现

the implementation of np.linalg.eig

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

已链接此处,链接到 _umath_linalg.py

_umath_linalg.py对应于< python3.6> /site-packages/numpy/linalg/_umath_linalg.cpython-36m-darwin.so

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

我搜索了很多关键字来自_umath_linalg.eig在cpython源代码上 gh repo 并没有任何关联。

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

在这种情况下,如何查找cpython源_umath_linalg.cpython-36m-darwin.so或 _umath_linalg.eig 的代码文件?

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

推荐答案

不同库在PyPi之外的确切位置并不是所有模块的共同位置,但通常它们位于github上。在这种情况下,您不是要查找cpython本身的来源,而是寻找numpy中的linalg模块的来源。向搜索引擎询问 numpy linalg github 为您提供位置

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.

您还可以使用 pip下载 将PyPi上任何可用模块的源代码下载到目录中你的选择。

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>

这篇关于如何查找特定第三方(例如NumPy)API的cpython源代码文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆