experiment with StringBuilder to guard strings under construction#448
Merged
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
Codecov Results 📊❌ Patch coverage is 0.93%. Project has 24223 uncovered lines. Files with missing lines (3)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
- Coverage 66.19% 66.10% -0.09%
==========================================
Files 279 281 +2
Lines 71052 71447 +395
Branches 152853 153474 +621
==========================================
+ Hits 47030 47224 +194
- Misses 24022 24223 +201
- Partials 3993 4044 +51Generated by Codecov Action |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
2 issues found across 5 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WIP, pushing to see pipeline feedback.
Summary by cubic
Introduce
StringBuilderto enforce resource-tracked string growth and prevent OOMs from unbounded intermediates. Adopt it in string padding and tab expansion so oversized builds fail fast withMemoryError.New Features
string_builder::StringBuilderthat reserves bytes with theResourceTrackeras it grows, and releases on drop/finish; 2× growth reduces tracker calls.fmt::Write; tracker errors surface viafinish. Added TODOs inpy_repr/py_strto route repr/str building throughStringBuilder.Bug Fixes
str.expandtabs,center,ljust,rjust, andzfillnow build viaStringBuilder, with exact-capacity reservations for bounded paths (s.len()+ pad) and safe 2× growth for unboundedexpandtabs.str_expandtabs_memory_limittest; expandedCLAUDE.mdwith builder guidance.Written for commit 6aeb9cd. Summary will update on new commits.