Skip to content

[0015] 优化 (liii list) 中 list-take 和 list-drop 的性能#782

Merged
da-liii merged 14 commits into
mainfrom
da/0015/liii_list_perf
May 9, 2026
Merged

[0015] 优化 (liii list) 中 list-take 和 list-drop 的性能#782
da-liii merged 14 commits into
mainfrom
da/0015/liii_list_perf

Conversation

@da-liii
Copy link
Copy Markdown
Contributor

@da-liii da-liii commented May 9, 2026

摘要

优化 (liii list)list-takelist-drop 函数的性能,避免 length 的全量遍历开销。

变更内容

  • list-take: 从 (length lst) + (take lst n) 改为单次 Scheme 循环遍历
  • list-drop: 从 (length lst) + (drop lst n) 改为单次 Scheme 循环遍历
  • list-take-right / list-drop-right: 经性能测试,原实现(调用 C 实现的 take-right / drop-right)更快,保留原实现
  • 添加 4 个 bench 文件和 devel/0015.md 开发文档

性能提升

函数 场景 提升
list-take 大列表取少量 (10000元素, 取10个) ~95%
list-drop 大列表丢弃少量 (10000元素, 丢弃10个) ~95%

测试

所有 56 个 liii/list 测试用例通过。

🤖 Generated with Claude Code

Da Shen and others added 14 commits May 9, 2026 10:18
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
性能测试表明原实现(调用 length + take-right/drop-right)
比纯 Scheme 实现更快,故保留原实现。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@da-liii da-liii merged commit 614bb1e into main May 9, 2026
4 checks passed
@da-liii da-liii deleted the da/0015/liii_list_perf branch May 9, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant