Repository navigation
Conversation
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.
Each trie read or write creates a C
FILEstream over the caller's descriptor and leaves it open. Repeated save/load and pickle operations retain the stream allocations and read buffers. Writes also ignore buffered flush failures, soBaseTrie.save('/dev/full')can report success.Give each C stream a duplicated descriptor and close it on success and failure, preserving the caller's file ownership and read position. Report failures when closing/flushing a write, and release a loaded trie if restoring the caller's position raises.
Validation:
update_c.shand the repository'stox -e pypass (44 tests, Python 3.10). The new BaseTrie flush-error case fails on current master; the other 30 file/trie tests pass there. A native stream-counter probe through 3,000 actual save/load cycles observes 6,000 retained streams on master and zero after this fix; measured RSS growth falls from about 26 MiB to less than 1 MiB. Another 521 lifecycle assertions cover caller file/position retention, descriptor reuse, interleaved records, BaseTrie/Trie pickling, malformed reads, wrong file modes, flush failures and caller seek errors, with no descriptor or stream retention.The full 44-test suite and 521 lifecycle assertions also pass on Python 3.14. Tests ran on Linux. Native Windows/macOS builds were not run. Reading after a Python file has prefetched a preceding record into its buffer still fails on both master and this patch; that existing buffering limitation is outside this change.