From 237e983770c7702ebeb52ece2614f10cd908d2f4 Mon Sep 17 00:00:00 2001 From: whitequark Date: Fri, 27 Nov 2015 18:22:55 +0800 Subject: [PATCH] compiler.types: replace isinstance() with .__class__==. This provides a 50% speedup. --- artiq/compiler/types.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/artiq/compiler/types.py b/artiq/compiler/types.py index 88f1ae302..a20743142 100644 --- a/artiq/compiler/types.py +++ b/artiq/compiler/types.py @@ -64,7 +64,7 @@ class TVar(Type): # because paths resulting from unification of large arrays # can easily cause a stack overflow. root = self - while isinstance(root, TVar): + while root.__class__ == TVar: if root is root.parent: break else: @@ -72,7 +72,7 @@ class TVar(Type): # path compression iter = self - while isinstance(iter, TVar): + while iter.__class__ == TVar: if iter is iter.parent: break else: