当前位置:首页>python>python高阶数据结构与算法优化

python高阶数据结构与算法优化

  • 2026-02-08 03:21:00
python高阶数据结构与算法优化

01

前言

Python基础数据结构,如list、tuple、dict、set,能满足简单开发需求,但在深度学习、测试等高阶场景中,面临数据处理效率、内存占用、任务响应速度等挑战。

本文主要讲下高阶数据结构(collections模块、array、heapq等)与算法优化(排序、搜索、贪心、动态规划),结合具体代码实例,讲解其核心用法与落地场景,助力提升Python程序性能。

核心目标:解决“基础数据结构效率不足”“算法冗余导致性能瓶颈”问题,适配大规模数据处理、实时任务调度、复杂路径规划等高阶需求。

02

高阶数据结构

高阶数据结构基于Python内置模块实现,在内存占用、查询速度、插入/删除效率上优于基础结构,是高阶开发的核心工具。

1. collections模块:高效容器扩展

collections是Python内置的“数据结构增强库”,提供了deque、defaultdict、OrderedDict、Counter、namedtuple等实用结构,解决基础容器的痛点。

1.1 deque(双端队列)

deque的核心优势是首尾插入/删除操作时间复杂度O(1),远优于list(O(n)),它还支持多线程安全操作,适合“队列/栈”场景(如任务队列、测试用例缓存)。

代码实例:机器人任务调度队列(先进先出)与历史任务栈(后进先出)

from collections importdeque# 1. 机器人任务队列(FIFO:先进先出)task_queue = deque()# 添加任务(尾部插入)task_queue.append("导航到充电桩")task_queue.append("执行障碍物检测")task_queue.append("返回起点")print("初始任务队列:", task_queue)  # deque(['导航到充电桩', '执行障碍物检测', '返回起点'])# 执行任务(头部删除)while task_queue:    current_task = task_queue.popleft()    print(f"正在执行任务:{current_task}")# 2. 机器人历史任务栈(LIFO:后进先出)history_stack = deque()history_stack.append("导航到充电桩")history_stack.append("执行障碍物检测")# 查看最近任务(尾部查看)print("最近执行任务:", history_stack[-1])  # 执行障碍物检测# 撤销最近任务(尾部删除)history_stack.pop()print("撤销后历史任务:", history_stack)  # deque(['导航到充电桩'])# 3. 限制队列长度(超出部分自动删除头部元素,适配缓存场景)cache_queue = deque(maxlen=3)for i in range(5):    cache_queue.append(f"缓存数据{i}")print("有限长度缓存队列:", cache_queue)  # deque(['缓存数据2', '缓存数据3', '缓存数据4'])

1.2 defaultdict

defaultdict直译为“有默认值的字典”,它主要解决“dict访问不存在的key报错”问题,自动为不存在的key生成默认值(如list、int、set),适合分组统计、数据聚合场景(如测试用例结果统计、深度学习数据分类)。

比如在使用普通dict分组数据时,得先判断key是否存在,写起来很麻烦。

代码实例:深度学习数据按类别分组、测试用例结果统计

from collections import defaultdict# 1. 深度学习数据按类别分组(默认值为list)data = [    ("cat""图像1.jpg"),    ("dog""图像2.jpg"),    ("cat""图像3.jpg"),    ("bird""图像4.jpg"),    ("dog""图像5.jpg")]# 定义defaultdict,默认值为listdata_group = defaultdict(list)for category, img_path in data:    data_group[category].append(img_path)  # 无需判断key是否存在,直接appendprint("按类别分组的数据:")for category, imgs in data_group.items():    print(f"{category}{imgs}")# 输出:# cat: ['图像1.jpg', '图像3.jpg']# dog: ['图像2.jpg', '图像5.jpg']# bird: ['图像4.jpg']# 2. 测试用例结果统计(默认值为int,实现计数)test_results = ["通过""失败""通过""通过""失败""跳过""通过"]result_count = defaultdict(int)for result in test_results:    result_count[result] += 1  # 不存在的key自动初始化为0print("测试用例结果统计:"dict(result_count))# 输出:{'通过': 4, '失败': 2, '跳过': 1}

1.3 Counter(计数字典)

一个“天生用来计数”的工具,给它一个列表/字符串,它能秒出每个元素的出现次数,还支持most_common(n)找前N个高频元素。语法简洁,适合频率统计场景(如文本词频、传感器数据频次)。

代码实例:文本词频统计、传感器数据频次分析

from collections import Counter# 1. 文本词频统计(NLP预处理常用)text = "Python 高阶 数据结构 数据结构 算法 优化 算法 Python 高阶 高阶"words = text.split()word_counter = Counter(words)print("所有词频:"dict(word_counter))# 输出:{'Python': 2, '高阶': 3, '数据结构': 2, '算法': 2, '优化': 1}# 获取出现频率最高的2个词print("Top2高频词:", word_counter.most_common(2))  # [('高阶', 3), ('Python', 2)]# 2. 传感器数据频次分析(统计激光雷达测距值出现次数)lidar_data = [1.21.51.22.01.51.23.12.01.5]lidar_counter = Counter(lidar_data)print("激光雷达测距值频次:"dict(lidar_counter))# 输出:{1.2: 3, 1.5: 3, 2.0: 2, 3.1: 1}

1.4 namedtuple(命名元组)

元组的元素只能用索引(比如t[0]、t[1])访问,不好记;namedtuple给每个元素起了名字,既能按名字访问,又保持元组的轻量和不可变性。兼具元组的不可变性与字典的可读性,内存占用远小于字典,适合存储“固定结构的小数据”(如坐标信息、测试用例信息)。

代码实例:坐标存储、测试用例信息封装

from collections import namedtuple# 1. 机器人坐标存储(x,y,z三维坐标)Point3D = namedtuple("Point3D", ["x""y""z"])# 创建坐标实例current_pos = Point3D(10.520.30.8)target_pos = Point3D(15.225.70.8)# 访问坐标(支持属性访问,比元组索引更易读)print(f"当前坐标:X={current_pos.x}, Y={current_pos.y}, Z={current_pos.z}")# 输出:当前坐标:X=10.5, Y=20.3, Z=0.8# 计算X轴距离x_distance = target_pos.x - current_pos.xprint(f"X轴距离:{x_distance}")  # 4.7# 2. 测试用例信息封装(用例ID、名称、优先级、状态)TestCase = namedtuple("TestCase", ["case_id""name""priority""status"])case1 = TestCase("TC001""接口登录测试""高""通过")case2 = TestCase("TC002""数据查询测试""中""失败")print("测试用例1信息:", case1)# 输出:TestCase(case_id='TC001', name='接口登录测试', priority='高', status='通过')print("用例2优先级:", case2.priority)  # 中

2. array模块:高效数值数组

list能存各种类型数据,但太占内存;array只存同类型数值(比如int、float),内存占用只有list的1/2~1/4,访问速度还更快,适合大规模数值数据处理(如深度学习样本、传感器原始数据)。

代码实例:大规模传感器数据存储与处理(对比list与array的内存占用)

importarrayimport sys# 1. 创建array数组(类型码'i'表示int,'f'表示float)# 存储机器人IMU传感器的加速度数据(10000个int值)imu_accel = array.array('i', [i*2for i in range(10000)])# 对比list与array的内存占用list_accel = [i*2for i in range(10000)]print(f"list内存占用:{sys.getsizeof(list_accel)} 字节"# 85176 字节print(f"array内存占用:{sys.getsizeof(imu_accel)} 字节")  # 40080 字节(节省一半内存)# 2.array核心操作(与list类似,但更高效)print("前5个加速度值:", imu_accel[:5])  # array('i', [0, 2, 4, 6, 8])# 追加数据imu_accel.append(20000)# 插入数据(指定索引)imu_accel.insert(0, -2)# 遍历数据for accel in imu_accel[:3]:    print(f"加速度值:{accel}")# 3. 保存到文件(适合大规模数据持久化)with open("imu_accel.bin""wb"as f:    imu_accel.tofile(f)# 从文件读取new_accel = array.array('i')with open("imu_accel.bin""rb"as f:    new_accel.fromfile(f, 10001)  # 读取10001个元素print("读取后的数据长度:"len(new_accel))  # 10001

3. heapq模块:堆结构(优先队列)

heapq实现最小堆(默认),它自动维护排序,支持O(1)获取最小值、O(logn)插入/删除元素,适合“优先任务调度”“TopN问题”(如紧急任务优先执行、深度学习样本优先级排序)。

代码实例:机器人任务优先级调度、获取TopN最大元素

import heapq# 1. 机器人任务优先级调度(优先级数值越小,优先级越高)# 任务格式:(优先级, 任务名称)tasks = [    (3"执行环境检测"),    (1"紧急避障"),    (2"导航到目标点"),    (4"采集传感器数据")]# 构建最小堆(默认)heapq.heapify(tasks)print("构建堆后的任务:", tasks)  # [(1, '紧急避障'), (3, '执行环境检测'), (2, '导航到目标点'), (4, '采集传感器数据')]# 优先执行高优先级任务(弹出最小值)print("任务执行顺序:")while tasks:    priority, task = heapq.heappop(tasks)    print(f"优先级{priority}{task}")# 输出:# 优先级1:紧急避障# 优先级2:导航到目标点# 优先级3:执行环境检测# 优先级4:采集传感器数据# 2. 实现最大堆(通过插入负数实现)nums = [528193]max_heap = []for num in nums:    heapq.heappush(max_heap, -num)  # 插入负数print("最大堆(存储负数):", max_heap)  # [-9, -5, -8, -1, -2, -3]# 获取最大值(弹出负数后取反)print("最大值:", -heapq.heappop(max_heap))  # 9# 3. 获取Top3最大元素top3 = heapq.nlargest(3, nums)print("Top3最大元素:", top3)  # [9, 8, 5]# 4. 获取Top2最小元素top2_min = heapq.nsmallest(2, nums)print("Top2最小元素:", top2_min)  # [1, 2]

03

算法优化

搞定了数据结构,再来说「算法优化」——好的算法能让你的代码“飞起来”,差的算法则会让代码卡顿。

算法优化核心是“降低时间复杂度/空间复杂度”,针对高阶场景中,我们重点讲4个高频算法:排序、搜索、贪心、动态规划,都是项目中必用的。

1. 排序算法优化:从O(n²)到O(nlogn)

基础排序(冒泡、插入)时间复杂度O(n²),适合小规模数据;高阶场景优先使用O(nlogn)算法(快速排序、归并排序),或Python内置sorted(底层为Timsort,融合归并+插入,效率最优),不用自己写排序算法!

代码实例:快速排序实现、Timsort应用(大规模数据排序)

import randomimport timefrom collections import namedtuple# 1. 快速排序(O(nlogn),不稳定排序,适合大规模数据)def quick_sort(arr):    iflen(arr) <= 1:        return arr    # 选择基准(优化:随机选择基准,避免最坏情况O(n²))    pivot = random.choice(arr)    left = [x for x in arr if x < pivot]    middle = [x for x in arr if x == pivot]    right = [x for x in arr if x > pivot]    return quick_sort(left) + middle + quick_sort(right)# 2. 对比基础排序(冒泡)与优化排序(快速排序、sorted)# 生成10000个随机整数(大规模数据)large_arr = [random.randint(0200000for _ in range(20000)]# 冒泡排序(O(n²),效率极低)def bubble_sort(arr):    arr_copy = arr.copy()    n = len(arr_copy)    for i in range(n):        for j in range(0, n-i-1):            if arr_copy[j] > arr_copy[j+1]:                arr_copy[j], arr_copy[j+1] = arr_copy[j+1], arr_copy[j]    return arr_copy# 测试耗时start = time.time()bubble_sort(large_arr)print(f"冒泡排序耗时:{time.time() - start:.2f} 秒")start = time.time()quick_sort(large_arr)print(f"快速排序耗时:{time.time() - start:.2f} 秒")start = time.time()sorted(large_arr)print(f"内置sorted排序耗时:{time.time() - start:.2f} 秒")# 3. 自定义排序(按对象属性排序,适配业务场景)# 机器人任务排序(按优先级升序,优先级相同按创建时间升序)Task = namedtuple("Task", ["name""priority""create_time"])tasks = [    Task("导航"2100),    Task("避障"1105),    Task("充电"298),    Task("检测"3102)]# 按优先级升序,再按创建时间升序sorted_tasks = sorted(tasks, key=lambda x: (x.priority, x.create_time))print("自定义排序后的任务:")for task in sorted_tasks:    print(f"{task.name}(优先级:{task.priority},创建时间:{task.create_time})")# 输出:# 避障(优先级:1,创建时间:105)# 充电(优先级:2,创建时间:98)# 导航(优先级:2,创建时间:100)# 检测(优先级:3,创建时间:102)

2. 搜索算法优化:二分查找(O(logn))

线性搜索(遍历)时间复杂度O(n),二分查找针对“有序数组”,时间复杂度O(logn),适合大规模有序数据查询

代码实例:二分查找实现(递归+迭代)、有序数据查询

# 1. 二分查找(迭代实现,推荐:避免递归栈溢出)def binary_search(arr, target):    left, right = 0len(arr) - 1    while left <= right:        mid = (left + right) // 2  # 中间索引(避免溢出:可改为left + (right-left)//2)        if arr[mid] == target:            return mid  # 返回目标索引        elif arr[mid] < target:            left = mid + 1  # 目标在右半部分        else:            right = mid - 1  # 目标在左半部分    return-1  # 目标不存在# 2. 二分查找(递归实现)def binary_search_recursive(arr, target, left, right):    if left > right:        return-1    mid = (left + right) // 2    if arr[mid] == target:        return mid    elif arr[mid] < target:        return binary_search_recursive(arr, target, mid + 1, right)    else:        return binary_search_recursive(arr, target, left, mid - 1)# 测试sorted_arr = [13579111315]target = 7print(f"迭代查找{target}的索引:", binary_search(sorted_arr, target))  # 3print(f"递归查找{target}的索引:", binary_search_recursive(sorted_arr, target, 0len(sorted_arr)-1))  # 3# 3. 实际场景:机器人路径点查询(有序路径点ID查询)path_points = [101102103105107109110]  # 有序路径点IDtarget_point = 105point_index = binary_search(path_points, target_point)if point_index != -1:    print(f"找到路径点{target_point},索引:{point_index}")else:    print(f"未找到路径点{target_point}")# 4. 内置bisect模块(二分查找工具,更简洁)import bisect# 查找插入位置(保持数组有序)insert_pos = bisect.bisect_left(sorted_arr, 8)print(f"8应插入的位置:{insert_pos}")  # 4(插入后数组仍有序)# 检查元素是否存在if bisect.bisect_left(sorted_arr, target) != len(sorted_arr) and sorted_arr[bisect.bisect_left(sorted_arr, target)] == target:    print(f"{target}存在于数组中")

3. 贪心算法:局部最优→全局最优

贪心算法就是“每次都选当前最优的选项”,不考虑未来,最后大概率能得到全局最优。适合“资源分配”“路径规划”等场景。

代码实例:

# 1. 机器人零钱兑换(贪心算法:优先选面额大的硬币,适合硬币面额为倍数关系)def coin_change_greedy(coins, amount):    """    coins: 硬币面额(降序排列)    amount: 需要兑换的金额    return: 最少硬币数    """    coins.sort(reverse=True)  # 按面额降序排序    count = 0    for coin in coins:        if amount <= 0:            break        # 尽可能多用当前面额        num = amount // coin        count += num        amount -= num * coin    return count if amount == 0else-1  # 无法兑换返回-1# 测试coins = [251051]  # 美元硬币(面额为倍数关系,贪心有效)amount = 37print(f"兑换{amount}需要最少硬币数:", coin_change_greedy(coins, amount))  # 4(25+10+1+1)# 2. 机器人活动安排问题(选择最多不重叠的活动,最大化任务数量)# 活动格式:(开始时间, 结束时间)activities = [    (13), (24), (35), (46), (57)]def activity_selection(activities):    # 按结束时间升序排序(贪心核心:选择结束最早的活动)    activities.sort(key=lambda x: x[1])    selected = [activities[0]]  # 选择第一个活动    last_end = activities[0][1]    for act in activities[1:]:        start, end = act        if start >= last_end:  # 不与上一个活动重叠            selected.append(act)            last_end = end    return selectedselected_acts = activity_selection(activities)print("最多可选择的不重叠活动:", selected_acts)  # [(1, 3), (3, 5), (5, 7)]

4. 动态规划:解决重叠子问题与最优子结构

核心思想是将复杂问题拆解为子问题,存储子问题解(避免重复计算),最终得到原问题解,适合“多阶段决策”场景(如机器人最长路径、深度学习模型超参数优化)。

代码实例:机器人走格子(最短路径数)、零钱兑换(任意面额,贪心无效时)

import sysdef unique_paths(m, n):    """    计算从 (0,0) 到 (m-1,n-1) 的最短路径数(只能右/下),并返回一条示例路径。    优化:不存储所有路径,用 parent 回溯,节省内存。    """    if m <= 0or n <= 0:        return0, []    if m == 1:        return1, [(0, j) for j in range(n)]    if n == 1:        return1, [(i, 0for i in range(m)]    # DP 数组    dp = [[0] * n for _ in range(m)]    # parent[i][j] = 'up' 表示从 (i-1,j) 来,'left' 表示从 (i,j-1) 来    parent = [[''] * n for _ in range(m)]    # 初始化    for i in range(m):        dp[i][0] = 1        if i > 0:            parent[i][0] = 'up'    for j in range(n):        dp[0][j] = 1        if j > 0:            parent[0][j] = 'left'    # DP 填表    for i in range(1, m):        for j in range(1, n):            dp[i][j] = dp[i-1][j] + dp[i][j-1]            # 任选一个来源(这里优先选上方)            parent[i][j] = 'up'  # 或根据 dp 值选择,但非必需    # 回溯构造路径    path = []    i, j = m - 1, n - 1    while i >= 0and j >= 0:        path.append((i, j))        if i == 0and j == 0:            break        if parent[i][j] == 'up':            i -= 1        else:  # 'left'            j -= 1    path.reverse()    # 可选:截断长路径(保持类型一致)    if len(path) > 10:        sample_path = path[:10]  # 不加 '...',避免类型混乱        print(f"Note: Path truncated to first 10 steps (total: {len(path)})")    else:        sample_path = path    return dp[m-1][n-1], sample_pathdef coin_change_dp(coins, amount):    """    动态规划求最少硬币数及换法。    """    if amount == 0:        return0, []    ifnot coins:        return-1, []    if min(coins) > amount:        return-1, []    dp = [sys.maxsize] * (amount + 1)    last_coin = [0] * (amount + 1)    dp[0] = 0    for i in range(1, amount + 1):        for coin in coins:            if coin <= i and dp[i - coin] != sys.maxsize and dp[i - coin] + 1 < dp[i]:                dp[i] = dp[i - coin] + 1                last_coin[i] = coin    if dp[amount] == sys.maxsize:        return-1, []    # 回溯换法(保持实际使用顺序)    change = []    current = amount    while current > 0:        coin = last_coin[current]        change.append(coin)        current -= coin    # 不排序,保留回溯顺序    return dp[amount], change# ===== 测试 =====if __name__ == "__main__":    # 测试 unique_paths    cnt, p = unique_paths(35)    print(f"3x5 路径数: {cnt}, 示例路径: {p}")    cnt2, p2 = unique_paths(55)    print(f"5x5 路径数: {cnt2}, 示例路径: {p2}")    # 测试 coin_change    print("\n--- Coin Change ---")    print(coin_change_dp([134], 6))      # (2, [3, 3])    print(coin_change_dp([151020], 36)) # (4, [...])    print(coin_change_dp([25], 3))         # (-1, [])    print(coin_change_dp([125], 0))      # (0, [])    print(coin_change_dp([], 10))            # (-1, [])

04

高阶场景应用总结

1. 核心选型建议

  • 数据处理效率优先:大规模数值数据用array,高频统计用Counter,分组用defaultdict
  • 任务调度/缓存:双端操作用deque,优先任务用heapq(堆)
  • 排序/搜索:大规模数据用sorted(Timsort),有序数据查询用二分查找
  • 复杂决策:局部最优用贪心,重叠子问题用动态规划

2. 性能优化关键点

  • 避免使用list进行高频首尾操作(改用deque),避免大规模数据用list存储(改用array)
  • 排序时优先用内置sorted(底层优化),自定义排序用lambda+key(比cmp高效)
  • 动态规划中用数组存储子问题解(避免递归重复计算),贪心算法需确认场景适配性(如硬币面额为倍数关系)
  • 多使用Python内置模块(collections、heapq、bisect),底层用C实现,效率远高于纯Python代码

以上高阶数据结构与算法,是Python在机器人、深度学习、测试等领域高效开发的核心基础。实际项目中,需结合场景选择合适的结构与算法,优先使用内置优化工具,平衡开发效率与程序性能。

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-08 16:41:38 HTTP/2.0 GET : https://f.mffb.com.cn/a/463633.html
  2. 运行时间 : 0.109385s [ 吞吐率:9.14req/s ] 内存消耗:4,540.77kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=4cf020965262746855f1aeaecb94de95
  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.000564s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000748s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000314s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000276s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000547s ]
  6. SELECT * FROM `set` [ RunTime:0.000260s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000601s ]
  8. SELECT * FROM `article` WHERE `id` = 463633 LIMIT 1 [ RunTime:0.005408s ]
  9. UPDATE `article` SET `lasttime` = 1770540098 WHERE `id` = 463633 [ RunTime:0.015988s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.003323s ]
  11. SELECT * FROM `article` WHERE `id` < 463633 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.003325s ]
  12. SELECT * FROM `article` WHERE `id` > 463633 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.004365s ]
  13. SELECT * FROM `article` WHERE `id` < 463633 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.001133s ]
  14. SELECT * FROM `article` WHERE `id` < 463633 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.000842s ]
  15. SELECT * FROM `article` WHERE `id` < 463633 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.005995s ]
0.110915s