arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~

理解Python重复结构:一项针对新手开发者的眼动追踪研究

Comprehending Python Repetition Structures: An Eye-Tracking Study with Novice Developers

José Júnior Silva da Costa, Rohit Gheyi, José Aldo Silva da Costa, Márcio Ribeiro

arXiv 2608.09875首次发表:更新:

AI 中文总结

本研究通过眼动实验对比Python的for循环、while循环、递归、列表推导式的理解难度,发现不同重复结构视觉投入模式不同,为代码可读性等提供过程层面证据。

AI 中文摘要

代码理解是软件维护与演化的核心,但不同的Python重复结构可能带来不同的认知需求。我们开展了一项受控眼动追踪实验,参与对象为32名有Python使用经验的本科生,旨在对比对for循环、while循环、递归及列表推导式(LCs)的理解情况。参与者采用拉丁方设计完成6项理解任务,我们在完整代码片段及特定结构的兴趣区(AOIs)上,测量了完成行为与眼动追踪指标。for循环的视觉投入最低;与for循环相比,while循环的AOI注视时长最多增加97%,回视次数最多增加114%,且回视集中在计数器管理部分;递归的回视次数呈描述性的50%增长,主要出现在基准情况与递归调用之间;列表推导式(LCs)的AOI时间增加62.5%,注视时长增加80.9%,其水平回视表明存在密集的逐标记解析。列表推导式的对比产生了最清晰的统计学显著成对差异,而所有非for结构的组合对比在所有眼动指标上均显著。这些发现提供了过程层面的证据,表明Python重复结构会引发不同的视觉投入模式,对可读性、代码审查、重构、新手入门及可维护性具有启示意义。

英文摘要

Code comprehension is central to software maintenance and evolution, yet different Python repetition structures may impose distinct cognitive demands. We conducted a controlled eye-tracking experiment with 32 undergraduate students with prior Python experience to compare comprehension of for loops, while loops, recursion, and list comprehensions (LCs). Participants solved six comprehension tasks in a Latin Square design while we measured completion behavior and eye-tracking metrics over full snippets and construct-specific Areas of Interest (AOIs). for loops showed the lowest visual effort. Relative to for, while loops increased AOI fixation duration by up to 97% and regression count by 114%, with regressions concentrated around counter management. Recursion showed a descriptive 50% increase in regressions, mainly between the base case and recursive call. LCs increased AOI time by 62.5% and fixation duration by 80.9%, with horizontal regressions suggesting dense token-by-token parsing. LC comparisons yielded the clearest statistically significant pairwise differences, while the combined comparison of all non-for structures was significant across all eye-tracking metrics. These findings provide process-level evidence that Python repetition structures induce distinct visual-effort patterns, with implications for readability, code review, refactoring, onboarding, and maintainability.

CommentsPaper accepted at Brazilian Symposium on Software Engineering (SBES) 2026

论文原文

arXiv 摘要页 · PDF 原文 · HTML 原文

↑