Skip to content

Commit

Permalink
Merge pull request #1967 from mattBoros/image-equals-fix
Browse files Browse the repository at this point in the history
Change equals method on Image so it short circuits
  • Loading branch information
hugovk committed Jun 20, 2016
2 parents 9fb0097 + 53c9a80 commit 08cb1db
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,16 +584,14 @@ def _dump(self, file=None, format=None):
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)
Expand Down

0 comments on commit 08cb1db

Please sign in to comment.