【问题标题】:How to find the implement python file of the python built in modules, ie itertools如何找到python内置模块的实现python文件,即itertools
【发布时间】:2021-11-12 06:08:13
【问题描述】:

我在windows os中使用anaconda,我正在尝试实现整个python环境的结构。

比如我想查看模块itertools的实现文件。但是,当我查看路径为anaconda3/envs/my_envs/Lib 的文件夹时,没有任何名为itertools.py 的python 文件。

如何从 docs.python.org 找到包含所有这些 implementations code 的确切文件

【问题讨论】:

  • 如何找到:打开解释器,导入需要的模块,输入导入模块的名称,回车。输出会告诉你在哪里可以找到它。

标签: python python-3.x


【解决方案1】:

您可以参考Cpython 源代码,它是 Python 的“官方”或参考实现。一些标准库模块在C(出于速度/系统调用/库绑定的目的)中实现,itertools 就是其中之一。你可以找到itertools.permutations 实现here

如果您想了解源代码的结构,可以参考Your Guide to the CPython Source Code。要了解C 扩展结构以及如何创建自己的扩展结构,请参考Extending Python with C or C++

【讨论】:

  • 是不是表示部分标准模块已经转换成c二进制文件或c库等?
猜你喜欢
  • 2020-04-07
  • 2010-09-21
  • 2013-05-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-16
相关资源
最近更新 更多