Inline isinstance check

This commit is contained in:
Hugo van Kemenade 2023-12-18 18:11:29 +02:00
parent a835bfb4d3
commit 368c05c9dc

View File

@ -20,10 +20,6 @@ import builtins
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 @@ class _Operand:
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)