From dd1e7ccc4aacde8972f7b2573a2b5029e2cb222d Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 3 Feb 2019 07:13:28 -0800 Subject: [PATCH] Slightly simplify Image.__eq__ Two identical types can be compared using the `is` operator. Object identity is slightly faster than a string comparison as well. --- src/PIL/Image.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index ef4a7a88a..62e5051fc 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -655,8 +655,7 @@ class Image(object): return filename def __eq__(self, other): - return (isinstance(other, Image) and - self.__class__.__name__ == other.__class__.__name__ and + return (self.__class__ is other.__class__ and self.mode == other.mode and self.size == other.size and self.info == other.info and