Skip to content

Commit 485066a

Browse files
committed
[GR-11635] Cache the wrapper for constant classess.
PullRequest: graalpython/227
2 parents 66df721 + a08a50b commit 485066a

File tree

1 file changed

+9
-2
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext

1 file changed

+9
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/CExtNodes.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,15 @@ Object doNativeNull(PythonNativeNull object) {
315315
return object.getPtr();
316316
}
317317

318-
@Specialization(guards = "!isNativeClass(object)")
319-
Object doPythonClass(PythonClass object) {
318+
@Specialization(guards = {"!isNativeClass(object)", "object == cachedObject"}, limit = "3")
319+
Object doPythonClass(@SuppressWarnings("unused") PythonClass object,
320+
@SuppressWarnings("unused") @Cached("object") PythonClass cachedObject,
321+
@Cached("wrap(object)") PythonClassNativeWrapper wrapper) {
322+
return wrapper;
323+
}
324+
325+
@Specialization(replaces = "doPythonClass", guards = {"!isNativeClass(object)"})
326+
Object doPythonClassUncached(PythonClass object) {
320327
return PythonClassNativeWrapper.wrap(object);
321328
}
322329

0 commit comments

Comments
 (0)