Repository navigation
Join lists and tuples directly in str.join - #8826
Conversation
Assisted-by: Claude Code:claude-opus-5-5
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: RustPython/RustPython/.coderabbit.yml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthrough
ChangesString Join Sequence Handling
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Refactor Merge Risk: ⚪ Minimal · up to No actionable issue is established for the new list and tuple join path; the change is mergeable after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
str.joinalways went through the iterator protocol: it created an iterator, looked up__length_hint__(allocating a bound method), and grew the result string item by item. For an exact list or tuple it now works on the items directly, as CPython'sPySequence_Fastdoes. It checks the items and sums their lengths, then builds the result in a single allocation. Other iterables keep the existing path. The list's read lock is held for the duration; no Python code runs while it's held.Performance
Instructions per call:
sep.join(...)Wall time:
','.join(row)over 50,000 CSV-style rows 35.3 → 10.8 ms;''.join(parts)of 200 chunks ×2,000 16.8 → 2.5 ms (CPython: 2.0 ms).AI assistance
Written with Claude Code (claude-opus-5-5): profiling, implementation, and testing were AI-assisted end to end, reviewed by a human before submission.
Summary by CodeRabbit
str.joinbehavior for lists, tuples, empty iterables, and generators.TypeErrorwith the expected message.str.