Repository navigation
Fix Deque maxlen enforcement when reopening persisted data - #396
Open
Harshit-2118 wants to merge 2 commits into
Open
Harshit-2118 wants to merge 2 commits into
Harshit-2118 wants to merge 2 commits into
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.
Fixes #395.
Reopening a populated
Dequewith a smallermaxlencurrently leaves the persisted contents over the limit, and subsequent appends never bring it back within the bound. Apply the existing transactionalmaxlensetter in bothDeque.__init__andDeque.fromcachebefore extending the supplied iterable, so older items are discarded from the left immediately. For the issue's example, reopening yields[2, 3, 4]and appending5yields[3, 4, 5].Add 24 regression cases against
collections.deque, covering both constructors, zero/unlimited/smaller/equal/larger limits, supplied iterables, append/appendleft, cache identity, and persistence after another reopen. Negative-limit behavior and publicmaxlen=Noneassignment are unchanged; those are covered by the separate work in #383 and #369.Validation on Linux with Python 3.12.16:
DJANGO_SETTINGS_MODULE=tests.settings python -m pytest -n 2— 275 passed, 3 Django deprecation warnings; 98.72% coverage (98% required).mypy diskcache, andgit diff --checkpassed. Flake8 ran in a separate environment with version 7.5.0 because the older dependency is incompatible with Python 3.12.These are local results. Other Python/OS combinations, documentation builds, and additional concurrency stress testing were not run; upstream CI results are separate.