Skip to content

馃攰 Warn when writing a large library with a deep-copying unparse stack - #615

Merged
MiWeiss merged 1 commit into
mainfrom
feat/warn-large-library-write-copy
Sep 3, 2026
Merged

馃攰 Warn when writing a large library with a deep-copying unparse stack#615
MiWeiss merged 1 commit into
mainfrom
feat/warn-large-library-write-copy

Conversation

@MiWeiss

@MiWeiss MiWeiss commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Why: The default unparse stack deep-copies every block (allow_inplace_modification=False). On a 90k-entry .bib that is ~85 % of write time: 5.6 s default vs 0.8 s with default_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_file log one logger.warning when the library has at least LARGE_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

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>
@MiWeiss
MiWeiss merged commit 3514d10 into main Sep 3, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant