mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Inline isinstance check
This commit is contained in:
parent
a835bfb4d3
commit
368c05c9dc
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user