mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
Changed equals method on Image so it short circuits. Also put getpalette() and tobytes() comparison at the end because they are the slowest operations.
This commit is contained in:
parent
9fb00976fc
commit
53c9a80d1b
18
PIL/Image.py
18
PIL/Image.py
|
@ -584,16 +584,14 @@ class Image(object):
|
|||
return file
|
||||
|
||||
def __eq__(self, other):
|
||||
if self.__class__.__name__ != other.__class__.__name__:
|
||||
return False
|
||||
a = (self.mode == other.mode)
|
||||
b = (self.size == other.size)
|
||||
c = (self.getpalette() == other.getpalette())
|
||||
d = (self.info == other.info)
|
||||
e = (self.category == other.category)
|
||||
f = (self.readonly == other.readonly)
|
||||
g = (self.tobytes() == other.tobytes())
|
||||
return a and b and c and d and e and f and g
|
||||
return (self.__class__.__name__ == other.__class__.__name__ and
|
||||
self.mode == other.mode and
|
||||
self.size == other.size and
|
||||
self.info == other.info and
|
||||
self.category == other.category and
|
||||
self.readonly == other.readonly and
|
||||
self.getpalette() == other.getpalette() and
|
||||
self.tobytes() == other.tobytes())
|
||||
|
||||
def __ne__(self, other):
|
||||
eq = (self == other)
|
||||
|
|
Loading…
Reference in New Issue
Block a user