Permalink
Browse files

Merged hash() calls.

Thanks Simon Charette for the review.
  • Loading branch information...
felixxm authored and timgraham committed Sep 28, 2017
1 parent fc6528b commit 2b5a511bd9fbd67cedf72b8d39b9522c0140d023
Showing with 3 additions and 9 deletions.
  1. +2 −8 django/db/models/expressions.py
  2. +1 −1 django/db/models/query.py
@@ -375,10 +375,7 @@ def __eq__(self, other):
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 @@ def get_group_by_cols(self):
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):
@@ -1416,7 +1416,7 @@ def __eq__(self, other):
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):

0 comments on commit 2b5a511

Please sign in to comment.