当前位置:首页>python>PyTorch封装后端前传: Python C 扩展的实现

PyTorch封装后端前传: Python C 扩展的实现

  • 2026-01-12 13:58:11
PyTorch封装后端前传: Python C 扩展的实现

扩展 Python 功能的方法有很多种。其中一种方法是用C/C++编写模块实现 Python 接口。这种方法可以提高性能,更好地访问 C 库函数和系统调用。

Python一个强大的功能是它能够调用C/C++定义的函数和库。这可以扩展程序的功能,扩展 Python 内置功能。

为什么要使用 C 语言呢?

🦚实现新的内置对象类型:可以用 C 语言编写Python 类,然后在 Python 上实例化并继承这样的类。这样做有很多原因,通常情况下,性能是促使开发者转向 C 语言的主要原因。了解 Python 的扩展能力非常有帮助。

🦚调用C库函数和系统调用:目前常用系统调用的接口,仍然只能通过 C 语言访问。PyTorch 大量使用了这种方法。比如,PyTorch 后端调用设备 runtime API。

本文主要说明如何使用 C/C++ 扩展 Python 模块。

要用 C 语言编写 Python 模块,需要使用Python API,定义了各种函数、宏和变量,使 Python 解释器能够调用自己编写的 C 代码。所有这些工具都包含在Python.h头文件中。

1
C语言编写代码, 扩展Python接口

我们编写一个简单的 C 函数,然后从 Python 调用它。实现包装器以更好地理解如何使用 C 语言扩展 Python 模块。

fputs()是一个简单的 C 函数,实现功能将字符串写入文件流:

intfputs(constchar *, FILE *)

函数有两个参数:const char * 是字符数组;FILE *是文件流指针。

fputs()将字符数组写入文件流指定的文件,返回一个非负值。如果操作成功,则该值表示写入文件的字节数。如果发生错误,则返回 0。C语言中的实现方法是打开文件 write.txt,把字符 "Hello Python C++!"写入文件。

#include<stdio.h>#include<stdlib.h>#include<unistd.h>intmain(){    FILE *fp = fopen("write.txt""w");    fputs("Hello Python C++!", fp);    fclose(fp);    return 1;}

上面这个代码 gcc 编译可以运行。

接下来,我们直接使用 Python.h 来封装这个功能。

#include<Python.h>static PyObject *method_fputs(PyObject *self, PyObject *args){    // 声明了希望从 Python 代码接收的参数类型    // 写入文件流的字符串, 要写入的文件的名字    char *str, *filename = NULL;    int bytes_copied = -1;    /* Parse arguments */    // PyArg_ParseTuple()将 从Python接收的参数解析为局部变量    // args 是 PyObject 类型    // "ss"是 标识符, 指明了解析的参数的数据类型    if(!PyArg_ParseTuple(args, "ss", &str, &filename)) {        return NULL;    }    FILE *fp = fopen(filename, "w");    // 在 Python 解释器内的调用    bytes_copied = fputs(str, fp);    fclose(fp);    // PyLong_FromLong()返回PyLongObject是Python中的整型对象    // 输入bytes_copied, 返回PyLong_FromLong 给 Python 解释器      return PyLong_FromLong(bytes_copied);}

这里使用了Python.h 中定义的三个对象或函数,这里主要说明一下 PyObject,其他两个函数已经在上面的代码中注释过:

🐤PyObject

🐤PyArg_ParseTuple()

🐤PyLong_FromLong()

PyObject 用于定义 Python 对象。所有 Python 对象都使用 PyObject 结构体定义的字段。所有对象类型都是这个类型的扩展。PyObject 包含了 Python 解释器需要的信息,将指向对象的指针视为对象。例如,将上述函数的返回类型设置为 PyObject,定义了有效的 Python 类型所需的通用字段,以便 Python 解释器可以识别该类型。

上面已经写好了 Python C 扩展功能代码。但是,要让模块正常运行,还需要编写模块和方法,如下所示:

static PyMethodDef FputsMethods[] = {    {"fputs", method_fputs, METH_VARARGS, "Python interface for fputs C library function"},    {NULLNULL0NULL}};static struct PyModuleDef fputsmodule = {    PyModuleDef_HEAD_INIT,    "fputs",    "Python interface for the fputs C library function",    -1,    FputsMethods};

这些变量包含了模块的元信息,这些信息提供给 Python 解释器使用。PyMethodDef 定义调用模块中的方法,需要告知 Python 解释器这些方法的存在。可以使用 PyMethodDef 结构体。这是一个包含 4 个成员的结构体,表示模块中的一个方法。通常 Python C 扩展模块中有多个方法被 Python 解释器调用。所以需要定义一个 PyMethodDef 结构体数组。

结构体中的每个成员都包含以下信息:

🦉"fputs" 这是用户输入以调用这个函数的名称。

🦉method_fputs 是要调用的 C 函数,之前已经定义过。

🦉METH_VARARGS 是一个标志位,用于指定扩展类型方法的调用约定,表示该方法采用标准的位置参数调用惯例。‌‌使用METH_VARARGS时,方法必须定义为PyCFunction类型‌,其函数签名接受两个参数:🪶self 指向方法所属的对象或模块,🪶args 一个元组对象,包含所有位置参数。这些参数使用通常通过PyArg_ParseTuple()或PyArg_UnpackTuple()宏解析,告诉解释器该函数有两个类型为 PyObject* 的参数。

🦉最后一个字符串是说明函数的文档字符串。

PyModuleDef  与 PyMethodDef 保存着 Python C 扩展模块中的方法信息一样, PyModuleDef 结构体保存着模块本身的信息。它不是结构体数组,只是模块定义的单个结构体。

typedef struct PyModuleDef{  PyModuleDef_Base m_base;  const char* m_name;  const char* m_doc;  Py_ssize_t m_size;  PyMethodDef *m_methods;  inquiry m_reload;  traverseproc m_traverse;  inquiry m_clear;  freefunc m_free;}PyModuleDef;

这个结构体共有 9 个成员,但不是所有成员都是必需的。在上面的代码块中,初始化了5个成员:

🦉PyModuleDef_HEAD_INIT 是 Python C API 中用于初始化模块定义结构体PyModuleDef 的宏,它将结构体的 m_base 成员设置为初始值,该值通常包含类型标识符和版本信息,以确保模块定义的正确性。‌它为模块定义结构体设置必要的头部信息,包括类型标识符(如 PyModuleDef_Type)和 API 版本,从而确保模块在创建时能被 Python 解释器正确识别和处理;在模块初始化函数中(如 PyInit_module_name),通常使用 PyModuleDef_Init() 或 PyModule_Create() 将此结构体转换为模块对象,此时 PyModuleDef_HEAD_INIT 会触发解释器对模块定义的验证。

🦉"fputs"是 Python C 扩展模块的名称。

🦉字符串是模块的文档字符串。设置 NULL 则不使用文档字符串,也可以传参指定文档字符串,使用 const char *。类型为 Py_ssize_t 。还可以使用 PyDoc_STRVAR() 为模块定义文档字符串。

🦉-1 模块的大小(以字节为单位),通常设置为 -1 表示自动计算。有以下值:

🪶负值表示该模块不支持子解释器。

🪶非负值允许重新初始化模块。指定了模块在每个子解释器会话中需要分配的内存。

🦉FputsMethods 指向 PyMethodDef 结构体数组的指针,用于描述模块中暴露的函数。这是之前定义的 PyMethodDef 结构体数组。

Python C 扩展的模块和方法已经写好了,现在要使用它们了。当 Python 程序第一次 import 模块时,它会调用PyInit_fputs():

PyMODINIT_FUNC PyInit_fputs(void) {    return PyModule_Create(&fputsmodule);}

PyMODINIT_FUNC 是 CPython C API 中的一个宏,声明扩展模块的初始化函数,该函数必须命名为 PyInit_ 加模块名(如 PyInit_fputs),并返回一个 PyObject* 指针,通常指向新创建的模块对象。‌主要作用是作为 Python 解释器与 C 扩展模块之间的入口点‌,当 Python 代码导入模块时,解释器会查找并调用此函数来完成模块的初始化,包括定义模块方法、创建类型对象等操作;该宏会处理平台相关的链接声明(如在 Windows 上添加 __declspec(dllexport))并确保函数在 C++ 中使用 extern "C" 链接,以避免名称修饰问题。‌

🏵️ 所以 PyMODINIT_FUNC 作为函数返回类型时,它隐式地执行 3 项操作:

🦉它隐式地将函数的返回类型设置为PyObject*。

🦉它声明了特殊链接。

🦉它将函数声明为 extern "C"。如果使用 C++,它会告诉 C++ 编译器不要对符号进行名称修饰。

🏵️ PyModule_Create() 是 Python C API 中用于创建模块对象的函数,属于ABI的一部分,自 Python 3.5 版本起可用。‌该函数的主要作用是创建模块对象:‌它输入一个模块对象 pyobject* 和一个模块定义结构体 pymoduledef*,并返回一个新的模块对象,类型为PyObject *。填入的参数是传递之前已定义的 fputsmodule 的地址。

2
流程梳理

我们回顾一下上面的流程。下图展示了模块的组件与 Python 解释器的交互:

当导入 Python C 扩展模块时,PyInit_fputs()是第一个调用的方法。在返回对象指针给 Python 解释器之前,函数会接着调用 PyModule_Create()。这将初始化包含模块元信息的 PyModuleDef 和 PyMethodDef 。在初始函数中会用到它们,需要预先准备好。

这些完成之后,模块对象的指针就会返回给 Python 解释器。下图就是模块的内部运行流程

PyModule_Create() 返回的模块对象带有指向模块 PyModuleDef 的指针,模块结构有指针指向方法 PyMethodDef。当调用 Python C 扩展模块中定义的方法时,Python 解释器会使用模块对象和携带的指针来执行具体的函数。这并不是 Python 解释器底层的处理方式,但可以了解它的运行方式。还可以访问模块的其他方法和属性,比如模块或方法docstring。这些都定义在各自的结构体中。

现在已经理解了Python解释器调用 fputs() 时会发生什么: 解释器会使用模块对象和模块的方法指针来调用这些方法。

最后,看看解释器是如何处理 Python C 扩展模块的实际执行流程的:

调用 method_fputs() 时, 程序执行以下步骤:

🦉使用 PyArg_ParseTuple() 解析从Python解释器传递的参数

🦉把参数传递给 fputs() 模块的 C 函数

🦉使用用PyLong_FromLong 返回 fputs()的值

总结一下,方法解析传递给模块的参数,发送给 fputs(),返回结果。

3
打包 Python C 扩展模块

在导入模块之前,需要先编译导入它,可以用 Python 包 distutils 或 setuptools 实现。需要编写 setup.py 文件编译安装应用程序。

最小 setup.py 文件实现如下所示:

from distutils.core import setup, Extensiondef main():    setup(name="fputs",          version="1.0.0",          description="Python interface for the fputs C library function",          author="<your name>",          author_email="email@gmail.com",          ext_modules=[Extension("fputs", ["fputsmodule.c"])])if __name__ == "__main__":    main()

setup() 的一个位置参数 ext_modules,是 Extensions 类对象的 list。Extensions 包装了 C/C++ 模块,传入2个参数到构造器里:name 模块名字 和 [filename] 源代码路径的的列表。

自此,使用 Python C APIs 封装、编译 C/C++ 代码或工具的具体方法和步骤就完成了。

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-09 00:44:38 HTTP/2.0 GET : https://f.mffb.com.cn/a/460793.html
  2. 运行时间 : 0.097893s [ 吞吐率:10.22req/s ] 内存消耗:4,687.55kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=1fdabf1c60bf8dafad4678a35f350584
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000667s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000983s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000370s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000277s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000508s ]
  6. SELECT * FROM `set` [ RunTime:0.000221s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000658s ]
  8. SELECT * FROM `article` WHERE `id` = 460793 LIMIT 1 [ RunTime:0.001098s ]
  9. UPDATE `article` SET `lasttime` = 1770569078 WHERE `id` = 460793 [ RunTime:0.003915s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000262s ]
  11. SELECT * FROM `article` WHERE `id` < 460793 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000522s ]
  12. SELECT * FROM `article` WHERE `id` > 460793 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000455s ]
  13. SELECT * FROM `article` WHERE `id` < 460793 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.000720s ]
  14. SELECT * FROM `article` WHERE `id` < 460793 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.008541s ]
  15. SELECT * FROM `article` WHERE `id` < 460793 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.006350s ]
0.099629s