馃攰 Warn when writing a large library with a deep-copying unparse stack - #615
Merged
Conversation
The default unparse stack deep-copies every block (middlewares with allow_inplace_modification=False), which dominates write time for large libraries: 5.6 s vs 0.8 s in-place on a 90k-entry .bib. Nothing told users they could opt out. write_string/write_file now log one warning when the library has at least LARGE_LIBRARY_WARNING_THRESHOLD (10_000) blocks and any middleware in the stack copies, pointing to default_unparse_stack(allow_inplace_modification=True). No behaviour change otherwise. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Why: The default unparse stack deep-copies every block (
allow_inplace_modification=False). On a 90k-entry.bibthat is ~85 % of write time: 5.6 s default vs 0.8 s withdefault_unparse_stack(allow_inplace_modification=True). Users who don't need the library afterwards can opt out, but nothing tells them.What:
write_string/write_filelog onelogger.warningwhen the library has at leastLARGE_LIBRARY_WARNING_THRESHOLD(10 000) blocks and any middleware in the stack copies, pointing to the in-place stack. No new parameters, no behaviour change otherwise.Tests: fires for the default stack at the threshold (constant monkeypatched down), not below it, not for an all-in-place stack; the suggested stack produces identical output. 2725 passed, 12 skipped.
馃 Generated with Claude Code