Skip to content

Commit 98d0507

Browse files
committed
cached isinstance call for arrow
1 parent 15ca0c7 commit 98d0507

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

synth/syntax/type_system.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ class Arrow(Type):
367367
def __init__(self, type_in: Type, type_out: Type):
368368
self.type_in = type_in
369369
self.type_out = type_out
370+
self.is_out_arrow = isinstance(self.type_out, Arrow)
370371
self.hash = hash((self.type_in, self.type_out))
371372

372373
def __pickle__(o: Type) -> Tuple:
@@ -414,15 +415,15 @@ def returns(self) -> Type:
414415
"""
415416
Get the return type of this arrow.
416417
"""
417-
if isinstance(self.type_out, Arrow):
418+
if self.is_out_arrow:
418419
return self.type_out.returns()
419420
return self.type_out
420421

421422
def arguments(self) -> TList[Type]:
422423
"""
423424
Get the list of arguments in the correct order of this arrow.
424425
"""
425-
if isinstance(self.type_out, Arrow):
426+
if self.is_out_arrow:
426427
return [self.type_in] + self.type_out.arguments()
427428
return [self.type_in]
428429

0 commit comments

Comments
 (0)