python - CPython 中 os.stat() 在哪里定义?

标签 python cpython

我查看了 CPython 源代码 ( Hg online here ),但我似乎找不到 os.stat() 的定义位置。看起来 stat 神奇地是 os 模块中的全局变量(Lib/os.py,ca. line 139)。

谁能告诉我合适的文件?

最佳答案

看起来像第 51 行(对于 UNIX;对于其他平台也有类似的行):

from posix import *

回溯,我们发现我们通过第29行的返回值到达了那个点:

_names = sys.builtin_module_names

并且posix_stat定义在Modules/posixmodule.c中:2301,最终被os调用:

static PyObject * posix_lstat(PyObject *self, PyObject *args, PyObject *kwargs) // ...

关于python - CPython 中 os.stat() 在哪里定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11475576/

相关文章:

python - 我们如何从Python文本中提取特定的测试

python - 在Python的C api中解析无符号整数(uint32_t)

python - Python 中是否有_rational_ 区间算术的实现?

python - python图形工具中的显式顶点位置

Python ctype - 如何在 C 函数之间传递数据

python - Plotly - 从颜色图中设置颜色循环

python - C Python : Running Python code within a context

python - 如何使用while循环遍历字典中的项目?

python - 是否可以用另一种语言为一种语言编写自动垃圾收集器?

Python:os.mkdir 的代码在哪里?