当前位置:首页>python>Python ctypes进阶:破解嵌套结构体与指针的内存迷宫

Python ctypes进阶:破解嵌套结构体与指针的内存迷宫

  • 2026-03-21 04:52:17
Python ctypes进阶:破解嵌套结构体与指针的内存迷宫

在跨语言编程场景中,Python通过ctypes模块与C语言交互时,处理嵌套结构体和包含指针的结构体是常见需求。

一、嵌套结构体的基础实现

1.1 简单嵌套结构体定义

C语言中常见的嵌套结构体示例:

// C语言定义
typedefstruct {
int x;
float y;
} Point;

typedefstruct {
    Point start;
    Point end;
char* name;
} LineSegment;

在Python中通过ctypes映射:

from ctypes import *

classPoint(Structure):
    _fields_ = [
        ("x", c_int),
        ("y", c_float)
    ]

classLineSegment(Structure):
    _fields_ = [
        ("start", Point),
        ("end", Point),
        ("name", c_char_p)  # 字符串指针处理
    ]

1.2 内存布局验证

通过sizeof()验证内存对齐:

print(sizeof(Point))      # 输出8 (4字节int + 4字节float)
print(sizeof(LineSegment)) # 输出24 (2*8字节Point + 8字节指针)

1.3 数据操作示例

# 创建结构体实例
line = LineSegment()
line.start.x = 10
line.start.y = 20.5
line.end.x = 30
line.end.y = 40.5
line.name = b"Test Line"# 字节字符串处理

# 访问嵌套字段
print(f"Start point: ({line.start.x}{line.start.y})")
print(f"Name: {line.name.decode()}")  # 字符串解码

二、包含指针的结构体处理

2.1 动态数组指针处理

考虑包含动态数组的结构体:

typedefstruct {
int count;
float* values;  // 动态数组指针
} DataArray;

Python实现方案:

classDataArray(Structure):
    _fields_ = [
        ("count", c_int),
        ("values", POINTER(c_float))  # 浮点数组指针
    ]

# 创建实例并分配内存
defcreate_data_array(count):
    arr = DataArray()
    arr.count = count
    arr.values = (c_float * count)(*[1.1*i for i inrange(count)])
return arr

# 使用示例
data = create_data_array(5)
for i inrange(data.count):
print(f"Value[{i}]: {data.values[i]}")  # 通过指针访问数组元素

2.2 指针的深拷贝处理

当结构体包含指针时,浅拷贝会导致指针共享问题:

from ctypes import *

classNode(Structure):
    _fields_ = [
        ("value", c_int),
        ("next", POINTER(Node))  # 自引用指针
    ]

# 创建链表
head = Node(1None)
head.next = pointer(Node(2None))
head.next.contents.next = pointer(Node(3None))

# 错误示范:浅拷贝
import copy
shallow_copy = copy.copy(head)  # 仅复制结构体本身
shallow_copy.value = 100
print(head.value)  # 仍为1,说明浅拷贝不影响原结构体

# 但指针仍共享同一内存
new_node = Node(200, head.next)
shallow_copy.next = pointer(new_node)
print(head.next.contents.value)  # 输出200,意外修改了原数据

正确深拷贝实现

defdeep_copy_node(original):
if original isNone:
returnNone

    new_node = Node()
    new_node.value = original.value
    new_node.next = deep_copy_node(original.next.contents) if original.nextelseNone
return pointer(new_node)  # 返回新指针

# 使用示例
original_head = Node(1, pointer(Node(2None)))
copied_head = deep_copy_node(original_head.contents)
copied_head.contents.value = 100
print(original_head.contents.value)  # 仍为1,深拷贝成功

三、复杂嵌套结构体案例

3.1 稀疏矩阵结构体

考虑包含嵌套指针的结构体:

// C语言定义
typedefstruct {
int row;
int col;
double value;
} MatrixElement;

typedefstruct {
int rows;
int cols;
int nnz;  // 非零元素数量
    MatrixElement* elements;  // 动态数组指针
} SparseMatrix;

Python完整实现:

classMatrixElement(Structure):
    _fields_ = [
        ("row", c_int),
        ("col", c_int),
        ("value", c_double)
    ]

classSparseMatrix(Structure):
    _fields_ = [
        ("rows", c_int),
        ("cols", c_int),
        ("nnz", c_int),
        ("elements", POINTER(MatrixElement))  # 元素数组指针
    ]

# 创建稀疏矩阵
defcreate_sparse_matrix(rows, cols, data):
"""
    data格式: [(row, col, value), ...]
    """

    mat = SparseMatrix()
    mat.rows = rows
    mat.cols = cols
    mat.nnz = len(data)

# 分配内存并初始化元素
    elements = (MatrixElement * mat.nnz)()
for i, (row, col, val) inenumerate(data):
        elements[i].row = row
        elements[i].col = col
        elements[i].value = val

    mat.elements = elements
return mat

# 使用示例
matrix_data = [
    (001.0),
    (112.0),
    (223.0)
]
sparse_mat = create_sparse_matrix(33, matrix_data)

# 遍历非零元素
for i inrange(sparse_mat.nnz):
    elem = sparse_mat.elements[i]
print(f"Element[{elem.row},{elem.col}]: {elem.value}")

3.2 树形结构体处理

处理包含子节点指针的树结构:

// C语言定义
typedefstructTreeNode {
int value;
structTreeNodeleft;
structTreeNoderight;
} TreeNode;

Python实现:

classTreeNode(Structure):
    _fields_ = [
        ("value", c_int),
        ("left", POINTER(TreeNode)),
        ("right", POINTER(TreeNode))
    ]

# 创建二叉树
defcreate_binary_tree():
# 创建叶子节点
    node3 = TreeNode()
    node3.value = 3
    node3.left = None
    node3.right = None

    node4 = TreeNode()
    node4.value = 4
    node4.left = None
    node4.right = None

# 创建中间节点
    node2 = TreeNode()
    node2.value = 2
    node2.left = pointer(node3)
    node2.right = None

# 创建根节点
    root = TreeNode()
    root.value = 1
    root.left = pointer(node2)
    root.right = pointer(node4)

return root

# 遍历二叉树(前序遍历)
deftraverse_tree(node):
if node isNone:
return
print(node.value, end=" ")
    traverse_tree(node.contents.left)
    traverse_tree(node.contents.right)

# 使用示例
root = create_binary_tree()
traverse_tree(pointer(root))  # 输出: 1 2 3 4

四、性能优化与安全考虑

4.1 内存管理最佳实践

  1. 1. 显式释放资源
# 对于动态分配的结构体数组
elements = (MatrixElement * 100)()
# 使用完毕后...
del elements  # Python垃圾回收会自动处理

# 更安全的做法(当结构体包含指针时)
deffree_sparse_matrix(mat):
if mat.elements:
# 在实际C代码中需要调用free(mat.elements)
# Python端仅需断开引用
        mat.elements = None
  1. 2. 使用byref替代指针(当不需要修改指针本身时):
from ctypes import byref

# 创建结构体
point = Point(1020.5)

# 传递引用而非指针
some_c_function(byref(point))  # 而不是 pointer(point)

4.2 类型安全检查

defvalidate_matrix(mat):
ifnotisinstance(mat, SparseMatrix):
raise TypeError("Expected SparseMatrix")
if mat.elements isNoneand mat.nnz > 0:
raise ValueError("Invalid matrix: nnz > 0 but elements is None")
if mat.elements isnotNoneand mat.nnz != len(mat.elements):
raise ValueError("nnz mismatch with elements array length")

4.3 字节序处理

当跨平台传输数据时需注意字节序:

import sys

# 检测系统字节序
is_little_endian = sys.byteorder == 'little'

# 强制使用小端序解析
classForceLittleEndian(Structure):
    _pack_ = 1# 禁用对齐填充
    _fields_ = [
        ("value", c_int)
    ]

# 在网络传输场景中显式指定字节序
defpack_data(value):
if is_little_endian:
return value.to_bytes(4'little')
else:
return value.to_bytes(4'big')

五、完整案例:解析C生成的二进制数据

假设C程序生成如下结构的二进制数据:

// C生成代码
typedefstruct {
uint32_t magic;
uint16_t version;
uint16_t entry_count;
    Entry* entries;  // 动态数组
} DataHeader;

typedefstruct {
uint32_t id;
char name[32];
float value;
} Entry;

Python解析实现:

from ctypes import *

classEntry(Structure):
    _fields_ = [
        ("id", c_uint32),
        ("name", c_char * 32),
        ("value", c_float)
    ]

classDataHeader(Structure):
    _fields_ = [
        ("magic", c_uint32),
        ("version", c_uint16),
        ("entry_count", c_uint16),
        ("entries", POINTER(Entry))
    ]

defparse_binary_data(data):
"""
    data: bytes对象,包含完整的二进制数据
    """

# 解析头部
    header_size = sizeof(DataHeader) - sizeof(POINTER(Entry))  # 减去指针字段
    header_data = data[:header_size]

# 使用from_buffer_copy创建临时缓冲区
    buffer = (c_byte * len(header_data)).from_buffer_copy(header_data)
    header = cast(buffer, POINTER(DataHeader)).contents

# 验证魔数
if header.magic != 0xDEADBEEF:
raise ValueError("Invalid magic number")

# 解析条目数组
    entry_size = sizeof(Entry)
    entries_data = data[header_size : header_size + header.entry_count * entry_size]

# 创建条目列表
    entries = []
for i inrange(header.entry_count):
        offset = i * entry_size
        entry_buffer = (c_byte * entry_size).from_buffer_copy(entries_data[offset:offset+entry_size])
        entry = cast(entry_buffer, POINTER(Entry)).contents
        entries.append(entry)

return header, entries

# 模拟二进制数据
defcreate_test_data():
# 创建条目
    entry1 = Entry()
    entry1.id = 1
    entry1.name = b"First Entry"
    entry1.value = 1.1

    entry2 = Entry()
    entry2.id = 2
    entry2.name = b"Second Entry"
    entry2.value = 2.2

# 创建头部
    header = DataHeader()
    header.magic = 0xDEADBEEF
    header.version = 1
    header.entry_count = 2
    header.entries = (Entry * 2)(entry1, entry2)

# 序列化为字节流
    header_size = sizeof(DataHeader) - sizeof(POINTER(Entry))
    entry_size = sizeof(Entry) * header.entry_count

# 手动构建字节流(实际应用中应从C程序获取)
from io import BytesIO
    bio = BytesIO()

# 写入头部(不含指针)
    bio.write(bytes(bytearray(header)[:header_size]))

# 写入条目
    bio.write(bytes(bytearray(header.entries)[:entry_size]))

return bio.getvalue()

# 测试解析
test_data = create_test_data()
header, entries = parse_binary_data(test_data)

print(f"Magic: 0x{header.magic:08X}")
print(f"Version: {header.version}")
print(f"Entry count: {header.entry_count}")

for i, entry inenumerate(entries):
print(f"\nEntry {i+1}:")
print(f"  ID: {entry.id}")
print(f"  Name: {entry.name.decode().strip()}")
print(f"  Value: {entry.value}")
  1. 1. 嵌套结构体处理:通过逐层定义_fields_实现嵌套映射,注意内存对齐和字节序问题。
  2. 2. 指针处理
    • • 使用POINTER(ctype)声明指针字段
    • • 动态数组需要通过额外字段记录长度
    • • 深拷贝需要递归处理所有指针字段
  3. 3. 内存管理
    • • 明确指针所有权,避免内存泄漏
    • • 在Python端仅断开引用,实际释放应在C端完成
    • • 使用byref替代指针当不需要修改指针本身时
  4. 4. 安全考虑
    • • 添加类型检查和边界验证
    • • 处理跨平台字节序问题
    • • 验证指针有效性后再访问
  5. 5. 性能优化
    • • 批量操作时考虑内存视图(memoryview)
    • • 避免不必要的数据拷贝
    • • 使用_pack_控制结构体对齐

通过掌握这些技术,开发者可以高效地在Python中处理复杂的C数据结构,实现跨语言的高性能计算和系统集成。

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-03-27 11:40:39 HTTP/2.0 GET : https://f.mffb.com.cn/a/481301.html
  2. 运行时间 : 0.224512s [ 吞吐率:4.45req/s ] 内存消耗:4,591.88kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=fb0af847ee48039d9b3d200ca002ddd0
  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.001307s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001677s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000918s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.001464s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001683s ]
  6. SELECT * FROM `set` [ RunTime:0.000556s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001491s ]
  8. SELECT * FROM `article` WHERE `id` = 481301 LIMIT 1 [ RunTime:0.001017s ]
  9. UPDATE `article` SET `lasttime` = 1774582839 WHERE `id` = 481301 [ RunTime:0.023335s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000804s ]
  11. SELECT * FROM `article` WHERE `id` < 481301 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.001891s ]
  12. SELECT * FROM `article` WHERE `id` > 481301 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001060s ]
  13. SELECT * FROM `article` WHERE `id` < 481301 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.004462s ]
  14. SELECT * FROM `article` WHERE `id` < 481301 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.002383s ]
  15. SELECT * FROM `article` WHERE `id` < 481301 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.002186s ]
0.228492s