From 368c05c9dc6f12528df2bbe254f2b6677c61b47f Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Mon, 18 Dec 2023 18:11:29 +0200 Subject: [PATCH] Inline isinstance check --- src/PIL/ImageMath.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/PIL/ImageMath.py b/src/PIL/ImageMath.py index 2c73acb9792..04718719522 100644 --- a/src/PIL/ImageMath.py +++ b/src/PIL/ImageMath.py @@ -20,10 +20,6 @@ from . import Image, _imagingmath -def _isconstant(v): - return isinstance(v, (int, float)) - - class _Operand: """Wraps an image operand, providing standard operators""" @@ -43,7 +39,7 @@ def __fixup(self, im1): raise ValueError(msg) else: # argument was a constant - if _isconstant(im1) and self.im.mode in ("1", "L", "I"): + if isinstance(im1, (int, float)) and self.im.mode in ("1", "L", "I"): return Image.new("I", self.im.size, im1) else: return Image.new("F", self.im.size, im1)