Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make use of collections.ChainMap to simplify the code #11522

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 2 additions & 5 deletions django/db/models/query_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import copy
import functools
import inspect
from collections import namedtuple
from collections import ChainMap, namedtuple

from django.db.models.constants import LOOKUP_SEP
from django.utils import tree
Expand Down Expand Up @@ -187,10 +187,7 @@ def merge_dicts(dicts):
Merge dicts in reverse to preference the order of the original list. e.g.,
merge_dicts([a, b]) will preference the keys in 'a' over those in 'b'.
"""
merged = {}
for d in reversed(dicts):
merged.update(d)
return merged
return ChainMap(*dicts)

@classmethod
def _clear_cached_lookups(cls):
Expand Down