mirror of https://github.com/django/django.git
Merged hash() calls.
Thanks Simon Charette for the review.
This commit is contained in:
parent
fc6528b25a
commit
2b5a511bd9
|
@ -375,10 +375,7 @@ class BaseExpression:
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
path, args, kwargs = self.deconstruct()
|
path, args, kwargs = self.deconstruct()
|
||||||
h = hash(path) ^ hash(args)
|
return hash((path,) + args + tuple(kwargs.items()))
|
||||||
for kwarg in kwargs.items():
|
|
||||||
h ^= hash(kwarg)
|
|
||||||
return h
|
|
||||||
|
|
||||||
|
|
||||||
class Expression(BaseExpression, Combinable):
|
class Expression(BaseExpression, Combinable):
|
||||||
|
@ -689,10 +686,7 @@ class RawSQL(Expression):
|
||||||
return [self]
|
return [self]
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
h = hash(self.sql) ^ hash(self.output_field)
|
return hash((self.sql, self.output_field) + tuple(self.params))
|
||||||
for param in self.params:
|
|
||||||
h ^= hash(param)
|
|
||||||
return h
|
|
||||||
|
|
||||||
|
|
||||||
class Star(Expression):
|
class Star(Expression):
|
||||||
|
|
|
@ -1416,7 +1416,7 @@ class Prefetch:
|
||||||
return isinstance(other, Prefetch) and self.prefetch_to == other.prefetch_to
|
return isinstance(other, Prefetch) and self.prefetch_to == other.prefetch_to
|
||||||
|
|
||||||
def __hash__(self):
|
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):
|
def normalize_prefetch_lookups(lookups, prefix=None):
|
||||||
|
|
Loading…
Reference in New Issue