summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2017-09-28 18:12:48 +0200
committerTim Graham <timograham@gmail.com>2017-09-28 12:12:47 -0400
commit2b5a511bd9fbd67cedf72b8d39b9522c0140d023 (patch)
tree2d9b83d8af7ff6be916bbfde0d13d03767345593
parentfc6528b25ab1834be1a478b405bf8f7ec5cf860c (diff)
Merged hash() calls.
Thanks Simon Charette for the review.
-rw-r--r--django/db/models/expressions.py10
-rw-r--r--django/db/models/query.py2
2 files changed, 3 insertions, 9 deletions
diff --git a/django/db/models/expressions.py b/django/db/models/expressions.py
index def866efbd..e11c32c9e7 100644
--- a/django/db/models/expressions.py
+++ b/django/db/models/expressions.py
@@ -375,10 +375,7 @@ class BaseExpression:
def __hash__(self):
path, args, kwargs = self.deconstruct()
- h = hash(path) ^ hash(args)
- for kwarg in kwargs.items():
- h ^= hash(kwarg)
- return h
+ return hash((path,) + args + tuple(kwargs.items()))
class Expression(BaseExpression, Combinable):
@@ -689,10 +686,7 @@ class RawSQL(Expression):
return [self]
def __hash__(self):
- h = hash(self.sql) ^ hash(self.output_field)
- for param in self.params:
- h ^= hash(param)
- return h
+ return hash((self.sql, self.output_field) + tuple(self.params))
class Star(Expression):
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 03de96ab2f..1fe0b4d045 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -1416,7 +1416,7 @@ class Prefetch:
return isinstance(other, Prefetch) and self.prefetch_to == other.prefetch_to
def __hash__(self):
- return hash(self.__class__) ^ hash(self.prefetch_to)
+ return hash((self.__class__, self.prefetch_to))
def normalize_prefetch_lookups(lookups, prefix=None):