8000 Remove ExceptionTypeCache · losttech/pythonnet@b88e72f · GitHub
[go: up one dir, main page]

Skip to content

Commit b88e72f

Browse files
Remove ExceptionTypeCache
- Removing `ExceptionTypeCache` which was causing issues and fix for issue caused performance overhead.
1 parent fcd62f6 commit b88e72f

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/runtime/interop.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,20 +125,13 @@ public static int Size(IntPtr ob)
125125
public static int ob_type;
126126
private static int ob_dict;
127127
private static int ob_data;
128-
private static readonly Dictionary<IntPtr, bool> ExceptionTypeCache = new Dictionary<IntPtr, bool>();
129128

130129
private static bool IsException(IntPtr pyObject)
131130
{
132-
bool res;
133131
var type = Runtime.PyObject_TYPE(pyObject);
134-
if (!ExceptionTypeCache.TryGetValue(type, out res))
135-
{
136-
res = Runtime.PyObjectType_TypeCheck(type, Exceptions.BaseException)
137-
|| Runtime.PyObjectType_TypeCheck(type, Runtime.PyTypeType)
138-
&& Runtime.PyType_IsSubtype(pyObject, Exceptions.BaseException);
139-
ExceptionTypeCache.Add(type, res);
140-
}
141-
return res;
132+
return Runtime.PyObjectType_TypeCheck(type, Exceptions.BaseException)
133+
|| Runtime.PyObjectType_TypeCheck(type, Runtime.PyTypeType)
134+
&& Runtime.PyType_IsSubtype(pyObject, Exceptions.BaseException);
142135
}
143136
}
144137

0 commit comments

Comments
 (0)
0