You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
(perf) Syntax word wrap without line numbers repeatedly renders each source line #4176
Syntax._get_syntax() currently calls console.render_lines(...) once per highlighted source line when word_wrap=True, even when line_numbers=False.
For syntax blocks without line numbers, continuation prefixes are not needed, so the selected highlighted lines can be joined and rendered/wrapped in one batch. This avoids repeatedly entering the generic console render pipeline.
The change batches Syntax._get_syntax() word-wrap rendering when line_numbers=False, so it avoids calling console.render_lines() once per source line. I also added a regression test covering the call count, and the syntax test module passes locally.
If someone with PR permissions wants to open the PR from that branch, the fix is ready.
@KRRT7 Thanks for the heads-up! I wasn't aware there was already a linked PR when I commented. In that case, it's all good as-is. Appreciate you letting me know.
@KRRT7 Yeah, pretty much 😅. I'm still very new to open source contributing and I'm honestly still figuring out how the GitHub workflow works. I saw the issue, worked on a fix, and didn't realize there was already a linked PR until you pointed it out. That's my mistake.
I'm still learning things like how to spot existing work before jumping in, so thanks for the heads-up. I'll be more careful to check for linked PRs and ongoing discussions first.
Activity
pavankumar-vh commentedon Jul 2, 2026
I implemented the optimization in my fork on branch
issue-4176-syntax-word-wrap-optand pushed it here:https://github.com/pavankumar-vh/rich/tree/issue-4176-syntax-word-wrap-opt
The change batches
Syntax._get_syntax()word-wrap rendering whenline_numbers=False, so it avoids callingconsole.render_lines()once per source line. I also added a regression test covering the call count, and the syntax test module passes locally.If someone with PR permissions wants to open the PR from that branch, the fix is ready.
KRRT7 commentedon Jul 2, 2026
@pavankumar-vh there is a linked PR...
pavankumar-vh commentedon Jul 2, 2026
@KRRT7 Thanks for the heads-up! I wasn't aware there was already a linked PR when I commented. In that case, it's all good as-is. Appreciate you letting me know.
KRRT7 commentedon Jul 2, 2026
@pavankumar-vh GitHub itself shows the linked PR, are you just asking your agent to go over open issues and resolve them?
pavankumar-vh commentedon Jul 2, 2026
@KRRT7 Yeah, pretty much 😅. I'm still very new to open source contributing and I'm honestly still figuring out how the GitHub workflow works. I saw the issue, worked on a fix, and didn't realize there was already a linked PR until you pointed it out. That's my mistake.
I'm still learning things like how to spot existing work before jumping in, so thanks for the heads-up. I'll be more careful to check for linked PRs and ongoing discussions first.
KRRT7 commentedon Jul 2, 2026
@pavankumar-vh no problem! feel free to join the discord if you're wanting to discuss anything or get advice!
pavankumar-vh commentedon Jul 2, 2026
@KRRT7 For sure, could you share me the invite link.