当前位置:首页>python>Python ctypes cast() 函数全解析:指针类型转换的终极指南

Python ctypes cast() 函数全解析:指针类型转换的终极指南

  • 2026-03-29 07:22:28
Python ctypes cast() 函数全解析:指针类型转换的终极指南

ctypes 是 Python 的一个外部函数库,提供了与 C 语言兼容的数据类型和调用接口。在处理指针类型时,经常需要在不同指针类型之间进行转换,这时 ctypes.cast() 函数就非常有用。

1. cast() 函数基础

1.1 函数原型

ctypes.cast(obj, typ)
  • • obj: 要转换的对象,通常是一个指针或可转换为指针的对象
  • • typ: 目标类型,必须是一个指针类型(如 c_void_pc_char_pPOINTER(c_int) 等)

1.2 功能说明

cast() 函数执行的是指针类型的转换,而不是内存内容的转换。它类似于 C 语言中的指针类型转换,只是改变了指针的"视图"方式,而不改变指针指向的内存地址。

1.3 与 C 语言指针转换的对比

在 C 语言中,指针类型转换通常这样写:

int *int_ptr = ...;
void *void_ptr = (void *)int_ptr;  // C 风格转换

在 Python 的 ctypes 中,等效的写法是:

from ctypes import *

int_ptr = pointer(c_int(42))
void_ptr = cast(int_ptr, c_void_p)

2. 基本指针类型转换案例

2.1 将 c_char_p 转换为 c_void_p

from ctypes import *

# 创建一个字符串指针
char_ptr = c_char_p(b"Hello, World!")
print(f"Original c_char_p: {char_ptr.value}")  # 输出: b'Hello, World!'

# 转换为 void 指针
void_ptr = cast(char_ptr, c_void_p)
print(f"Cast to c_void_p: {void_ptr.value}")  # 输出: 内存地址 (如 140732920751888)

# 注意: c_void_p 的 value 属性返回的是内存地址
# 要获取原始字符串,需要再转换回去
char_ptr_back = cast(void_ptr, c_char_p)
print(f"Cast back to c_char_p: {char_ptr_back.value}")  # 输出: b'Hello, World!'

2.2 将 c_void_p 转换为具体类型指针

from ctypes import *

# 创建一个整数
num = c_int(42)
# 获取指向它的指针
int_ptr = pointer(num)

# 转换为 void 指针
void_ptr = cast(int_ptr, c_void_p)
print(f"Void pointer value: {void_ptr.value}")  # 输出内存地址

# 转换回 int 指针
int_ptr_back = cast(void_ptr, POINTER(c_int))
print(f"Integer value: {int_ptr_back.contents.value}")  # 输出: 42

3. 结构体指针转换案例

3.1 基本结构体指针转换

from ctypes import *

# 定义一个结构体
classPoint(Structure):
    _fields_ = [("x", c_int),
                ("y", c_int)]

# 创建结构体实例
p = Point(1020)

# 获取结构体指针
point_ptr = pointer(p)
print(f"Original Point: x={p.x}, y={p.y}")

# 转换为 void 指针
void_ptr = cast(point_ptr, c_void_p)
print(f"Void pointer value: {void_ptr.value}")  # 输出内存地址

# 转换回 Point 指针
point_ptr_back = cast(void_ptr, POINTER(Point))
print(f"Cast back Point: x={point_ptr_back.contents.x}, y={point_ptr_back.contents.y}")

3.2 处理结构体数组

from ctypes import *

classPerson(Structure):
    _fields_ = [("name", c_char * 20),
                ("age", c_int)]

# 创建结构体数组
person_array = (Person * 3)(
    Person(b"Alice"25),
    Person(b"Bob"30),
    Person(b"Charlie"35)
)

# 获取数组指针
array_ptr = cast(person_array, POINTER(Person))

# 遍历数组
for i inrange(3):
    person = array_ptr[i]
print(f"Person {i}: Name={person.name.decode()}, Age={person.age}")

4. 函数指针转换案例

4.1 基本函数指针转换

from ctypes import *

# 定义两个函数
defadd(a, b):
return a + b

defmultiply(a, b):
return a * b

# 创建函数指针
add_ptr = CFUNCTYPE(c_int, c_int, c_int)(add)
mul_ptr = CFUNCTYPE(c_int, c_int, c_int)(multiply)

# 转换为 void 指针
add_void = cast(add_ptr, c_void_p)
mul_void = cast(mul_ptr, c_void_p)

print(f"Add function address: {add_void.value}")
print(f"Multiply function address: {mul_void.value}")

# 转换回函数指针
add_ptr_back = cast(add_void, CFUNCTYPE(c_int, c_int, c_int))
mul_ptr_back = cast(mul_void, CFUNCTYPE(c_int, c_int, c_int))

print(f"5 + 3 = {add_ptr_back(53)}")
print(f"5 * 3 = {mul_ptr_back(53)}")

4.2 回调函数中的指针转换

from ctypes import *

# 定义回调函数类型
CALLBACK_FUNC = CFUNCTYPE(None, c_int, c_void_p)

# 回调函数实现
defcallback(value, user_data):
# 将 user_data 转换回原始类型
    data_ptr = cast(user_data, POINTER(c_int))
    original_value = data_ptr.contents.value
print(f"Callback called with value={value}, original data={original_value}")

# 创建回调函数
cb = CALLBACK_FUNC(callback)

# 准备用户数据
user_data = c_int(100)
user_data_ptr = pointer(user_data)
void_ptr = cast(user_data_ptr, c_void_p)

# 模拟调用回调函数 (在实际中可能是由C库调用的)
print("Simulating callback call:")
cb(42, void_ptr)

5. 内存操作与指针转换

5.1 分配和操作内存块

from ctypes import *

# 分配内存块
buffer_size = 1024
buffer = (c_ubyte * buffer_size)()

# 填充一些数据
for i inrange(buffer_size):
    buffer[i] = i % 256

# 获取指针
buffer_ptr = cast(buffer, c_void_p)
print(f"Buffer address: {buffer_ptr.value}")

# 转换为其他指针类型进行操作
# 例如作为整数数组访问
int_array_ptr = cast(buffer_ptr, POINTER(c_int))
print(f"First 4 bytes as int: {int_array_ptr[0]}")  # 注意字节序问题

# 转换为字符指针
char_ptr = cast(buffer_ptr, c_char_p)
print(f"First 10 bytes as string: {char_ptr.value[:10]}")  # 可能显示乱码

5.2 与 C 库交互的内存处理

from ctypes import *

# 假设我们有一个C库函数需要 void* 参数
# 这里我们模拟一个C函数
defc_library_function(data_ptr, size):
# 在实际应用中,这里会是真正的C函数调用
print(f"C function received pointer: {data_ptr.value}")
print(f"Size: {size}")

# 修改数据 (在实际中可能是C库修改的)
    int_ptr = cast(data_ptr, POINTER(c_int))
    int_ptr.contents.value += 100

# 准备数据
num = c_int(42)
num_ptr = pointer(num)
void_ptr = cast(num_ptr, c_void_p)

# 调用"C库函数"
c_library_function(void_ptr, sizeof(c_int))

# 查看修改后的结果
print(f"Modified value: {num.value}")  # 输出: 142

6. 高级应用:处理复杂数据结构

6.1 处理链表结构

from ctypes import *

classListNode(Structure):
    _fields_ = [("value", c_int),
                ("next", POINTER(ListNode))]

# 创建链表: 1 -> 2 -> 3
node3 = ListNode(3None)
node2 = ListNode(2, pointer(node3))
node1 = ListNode(1, pointer(node2))

# 遍历链表
current = pointer(node1)
while current:
    node = current.contents
print(node.value, end=" -> ")
    current = node.next
print("None")

# 转换为 void 指针数组 (模拟)
# 在实际应用中,可能需要这样处理来自C的链表
void_ptrs = []
current = pointer(node1)
while current:
    void_ptrs.append(cast(current, c_void_p))
    node = current.contents
    current = node.next

print("\nVoid pointers in list:")
for ptr in void_ptrs:
print(hex(ptr.value))

# 从 void 指针恢复链表
restored_list = []
for ptr in void_ptrs:
    node_ptr = cast(ptr, POINTER(ListNode))
    restored_list.append(node_ptr.contents.value)

print("Restored list values:", restored_list)  # 输出: [1, 2, 3]

6.2 处理树结构

from ctypes import *

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

# 创建二叉树
#       1
#      / \
#     2   3
#    / \
#   4   5
node5 = TreeNode(5NoneNone)
node4 = TreeNode(4NoneNone)
node2 = TreeNode(2, pointer(node4), pointer(node5))
node3 = TreeNode(3NoneNone)
root = TreeNode(1, pointer(node2), pointer(node3))

# 中序遍历函数
definorder_traversal(node_ptr):
ifnot node_ptr:
return []

    node = node_ptr.contents
    left_values = inorder_traversal(node.left)
    right_values = inorder_traversal(node.right)

return left_values + [node.value] + right_values

print("Inorder traversal:", inorder_traversal(pointer(root)))  # 输出: [4, 2, 5, 1, 3]

# 序列化树结构为 void 指针列表 (模拟)
defserialize_tree(node_ptr):
ifnot node_ptr:
return []

    node = node_ptr.contents
    left_ptrs = serialize_tree(node.left)
    right_ptrs = serialize_tree(node.right)

# 当前节点指针转换为 void 指针
    current_void = cast(node_ptr, c_void_p)

return [current_void] + left_ptrs + right_ptrs

void_ptr_list = serialize_tree(pointer(root))
print("\nSerialized tree (void pointers):")
for ptr in void_ptr_list:
print(hex(ptr.value))

# 从 void 指针列表恢复树结构 (简化版)
# 在实际应用中,需要更复杂的逻辑来重建树结构
print("\nAttempt to restore tree values (simplified):")
for ptr in void_ptr_list[:1]:  # 只处理根节点
    node_ptr = cast(ptr, POINTER(TreeNode))
print("Root value:", node_ptr.contents.value)  # 输出: 1

7. 注意事项与最佳实践

7.1 类型安全

  • • cast() 不会进行类型检查,错误的转换可能导致段错误或数据损坏
  • • 确保转换后的指针类型与实际数据类型匹配

7.2 内存管理

  • • cast() 不改变对象的所有权或生命周期
  • • 确保指针在转换前后都有效
  • • 避免悬垂指针

7.3 字节序问题

  • • 当在不同整数类型的指针间转换时,注意字节序问题
  • • 特别是在不同平台间交互时

7.4 最佳实践示例

from ctypes import *

defsafe_cast_example():
# 创建原始数据
    data = (c_int * 3)(123)

# 安全转换: 从数组指针到 void 指针
    void_ptr = cast(data, c_void_p)
print(f"Void pointer: {void_ptr.value}")

# 安全转换: 从 void 指针回到数组指针
# 首先计算元素大小和数量
    element_size = sizeof(c_int)
    array_length = 3

# 确保目标类型匹配
if element_size * array_length <= 0x100000000:  # 简单的安全检查
        array_ptr = cast(void_ptr, POINTER(c_int * array_length))
        restored_data = array_ptr.contents
print(f"Restored data: {list(restored_data)}")  # 输出: [1, 2, 3]
else:
print("Error: Potential buffer overflow")

safe_cast_example()

8. 完整综合案例

from ctypes import *
import random

# 定义复杂数据结构
classStudent(Structure):
    _fields_ = [("id", c_int),
                ("name", c_char * 20),
                ("scores", POINTER(c_float)),  # 动态数组
                ("count", c_int)]

# 创建学生数据
defcreate_student(id, name, scores):
# 创建学生结构体
    student = Student()
    student.id = id

# 复制名字 (确保以null结尾)
    name_bytes = name.encode('utf-8')[:19] + b'\0'
for i inrange(20):
if i < len(name_bytes):
            student.name[i] = name_bytes[i]
else:
            student.name[i] = 0

# 创建分数数组
    student.count = len(scores)
    float_array = (c_float * len(scores))(*scores)
    student.scores = cast(float_array, POINTER(c_float))

return student

# 打印学生信息
defprint_student(student_ptr):
    student = student_ptr.contents
    name = student.name.decode('utf-8').rstrip('\0')
    scores = [student.scores[i] for i inrange(student.count)]
print(f"Student ID: {student.id}, Name: {name}, Scores: {scores}")

# 主程序
defmain():
# 创建学生
    student1 = create_student(1001b"Alice", [85.592.078.5])
    student2 = create_student(1002b"Bob", [76.088.595.0])

# 创建学生数组
    students = (Student * 2)(student1, student2)

# 获取数组指针
    students_ptr = cast(students, POINTER(Student))

# 遍历学生数组
print("All students:")
for i inrange(2):
        print_student(students_ptr + i)  # 或者 students_ptr[i]

# 模拟将学生数据传递给C函数 (使用void指针)
defprocess_students(data_ptr, count):
print("\nProcessing students in C-style function:")
for i inrange(count):
# 将void指针转换回Student指针
            student_ptr = cast(cast(data_ptr, POINTER(POINTER(Student)))[i], 
                              POINTER(Student))
            print_student(student_ptr)

# 为了模拟C函数的参数,我们需要创建一个指针数组
# 首先创建指向每个学生的指针
    student_ptrs = (POINTER(Student) * 2)()
for i inrange(2):
        student_ptrs[i] = students_ptr + i

# 获取指针数组的void指针
    ptrs_void = cast(student_ptrs, c_void_p)

# 模拟调用C函数 (在实际中,ptrs_void和2会是C函数的参数)
print("\nSimulating C function call:")
    process_students(ptrs_void, 2)

# 更真实的模拟: 创建一个连续的void指针数组
# 在实际应用中,C函数可能期望一个连续的指针数组
print("\nMore realistic simulation:")
# 分配内存存储指针数组
    ptr_array_size = sizeof(POINTER(Student)) * 2
    ptr_array_buffer = create_string_buffer(ptr_array_size)
    ptr_array = cast(ptr_array_buffer, POINTER(POINTER(Student)))

# 填充指针数组
for i inrange(2):
        ptr_array[i] = students_ptr + i

# 现在ptr_array_buffer.raw是连续的指针数组内存
# 我们可以直接传递ptr_array_buffer或cast(ptr_array_buffer, c_void_p)

# 模拟C函数处理
defreal_c_function(ptr_array_void, count):
print("\nInside real C function simulation:")
        ptr_array = cast(ptr_array_void, POINTER(POINTER(Student)))
for i inrange(count):
            print_student(ptr_array[i])

    real_c_function(cast(ptr_array_buffer, c_void_p), 2)

if __name__ == "__main__":
    main()

9. 总结

ctypes.cast() 是 Python ctypes 库中一个强大但需要谨慎使用的工具,它允许在不同指针类型之间进行转换。主要应用场景包括:

  1. 1. 与 C 库交互时处理泛型 void* 参数
  2. 2. 在不同但兼容的指针类型间转换
  3. 3. 实现复杂数据结构的序列化和反序列化
  4. 4. 处理回调函数中的用户数据

使用时需要注意:

  • • 确保转换的类型与实际数据类型兼容
  • • 注意内存管理和对象生命周期
  • • 避免在转换后访问无效内存
  • • 在性能关键代码中谨慎使用,因为过度使用可能影响性能

通过合理使用 cast(),可以更灵活地处理与 C 库的交互,实现更复杂的内存操作模式。

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-03-29 14:33:09 HTTP/2.0 GET : https://f.mffb.com.cn/a/483751.html
  2. 运行时间 : 0.153954s [ 吞吐率:6.50req/s ] 内存消耗:4,523.58kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=0ba676f7aaa9fa7659e63594dcb65149
  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.000745s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000717s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000430s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000276s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000465s ]
  6. SELECT * FROM `set` [ RunTime:0.000206s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000562s ]
  8. SELECT * FROM `article` WHERE `id` = 483751 LIMIT 1 [ RunTime:0.000779s ]
  9. UPDATE `article` SET `lasttime` = 1774765989 WHERE `id` = 483751 [ RunTime:0.003568s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000238s ]
  11. SELECT * FROM `article` WHERE `id` < 483751 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000413s ]
  12. SELECT * FROM `article` WHERE `id` > 483751 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000357s ]
  13. SELECT * FROM `article` WHERE `id` < 483751 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.000765s ]
  14. SELECT * FROM `article` WHERE `id` < 483751 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.001042s ]
  15. SELECT * FROM `article` WHERE `id` < 483751 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.001280s ]
0.155583s