Repository navigation
Match common encoding names before normalizing them - #8862
Conversation
Assisted-by: Claude Code:claude-opus-5-5 Assisted-by: Codex:GPT-6
|
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; 9 remain after this review. 📝 WalkthroughWalkthroughFastCodec now directly recognizes seven common UTF-8, ASCII, and Latin-1 spellings before normalization. Added tests check encoding and decoding results, plus canonical codec names in errors. ChangesCodec spelling recognition
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Refactor Merge Risk: ⚪ Minimal · up to The recognized spellings retain their existing encode and decode behavior; this change only avoids normalization work, so no material merge risk is apparent. 🚥 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 |
Merging this PR will not alter performance
Comparing Footnotes
|
Summary
bytes.decode()andstr.encode()select the built-in UTF-8, ASCII or Latin-1 codec throughFastCodec::classify. Normalizing the defaultutf-8spelling allocates a new string on each call before searching the alias lists.Match
utf-8,utf8,UTF-8,ascii,latin-1,latin1andiso-8859-1directly before normalization. These spellings retain their existing codec selection; other names follow the existing normalization and lookup path.Follow-up to #8737, which introduced the native codec fast paths.
Performance
Windows x64 release build; medians of five samples of 200,000 calls.
str.encode()bytes.decode("latin-1")str.encode("latin-1")AI assistance
Written with Claude Code (claude-opus-5-5) and Codex (GPT-6), reviewed by a human before submission.
Summary by CodeRabbit