Conversation
Keep argument groups distinct to prevent positional tuples from colliding with keyword pairs. Cover both call orders and repeated cache hits.
UditDewan
requested review from
asvishnyakov,
hayescode and
sandangel
as code owners
September 16, 2026 02:57
This branch has not been deployed
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 #3045.
Calling a cached function with
("value", 1)as a positional argument and then withvalue=1currently returns the first result for both calls. The cache key concatenates positional arguments and keyword pairs, so these distinct calls become indistinguishable.Keep the function, positional arguments, and sorted keyword pairs in separate tuple fields. This preserves function isolation, keyword-order independence, and the existing locking behavior.
Validation on Python 3.13.7:
PYTHONPATH=backend python -m pytest backend/tests/test_cache.py -q: 26 passed.git diff --checkpassed.The test also repeats both calls and checks that the function executes only once per distinct input.
Summary by cubic
Fixes #3045. Calling a cached function with
("value", 1)as a positional argument and then withvalue=1previously returned the same result for both calls because both produced the same cache key. The key now stores the positional arguments and sorted keyword pairs in separate tuple fields, so these calls get distinct cache entries. The regression test covers both call orders and verifies the function runs only once per distinct input.Written for commit 58f7696. Summary will update on new commits.