Skip to content

Commit 593e23d

Browse files
committed
perf improvement
1 parent a06bb9d commit 593e23d

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,22 +2577,23 @@ private static HiddenKey createTypeKey(String name) {
25772577
private void addDictDescrAttribute(PythonAbstractClass[] basesArray, PythonClass pythonClass) {
25782578
// Note: we need to avoid MRO lookup of __dict__ using slots because they are not
25792579
// initialized yet
2580-
if ((!hasPythonClassBases(basesArray) &&
2581-
LookupAttributeInMRONode.lookupSlowPath(pythonClass, __DICT__) == PNone.NO_VALUE) ||
2582-
basesHaveSlots(basesArray)) {
2583-
Builtin dictBuiltin = ObjectBuiltins.DictNode.class.getAnnotation(Builtin.class);
2580+
if ((!hasPythonClassBases(basesArray) && LookupAttributeInMRONode.lookupSlowPath(pythonClass, __DICT__) == PNone.NO_VALUE) || basesHaveSlots(basesArray)) {
25842581
RootCallTarget callTarget = PythonLanguage.getCurrent().createCachedCallTarget(
2585-
l -> new BuiltinFunctionRootNode(l, dictBuiltin, new StandaloneBuiltinFactory<PythonBinaryBuiltinNode>(DictNodeGen.create()), true), dictBuiltin,
2586-
StandaloneBuiltinFactory.class);
2582+
l -> {
2583+
Builtin dictBuiltin = ObjectBuiltins.DictNode.class.getAnnotation(Builtin.class);
2584+
return new BuiltinFunctionRootNode(l, dictBuiltin, new StandaloneBuiltinFactory<PythonBinaryBuiltinNode>(DictNodeGen.create()), true);
2585+
}, ObjectBuiltins.DictNode.class, StandaloneBuiltinFactory.class);
25872586
setAttribute(__DICT__, callTarget, pythonClass);
25882587
}
25892588
}
25902589

25912590
@TruffleBoundary
25922591
private void addWeakrefDescrAttribute(PythonClass pythonClass) {
2593-
Builtin builtin = GetWeakRefsNode.class.getAnnotation(Builtin.class);
25942592
RootCallTarget callTarget = PythonLanguage.getCurrent().createCachedCallTarget(
2595-
l -> new BuiltinFunctionRootNode(l, builtin, WeakRefModuleBuiltinsFactory.GetWeakRefsNodeFactory.getInstance(), true), builtin, WeakRefModuleBuiltinsFactory.class);
2593+
l -> {
2594+
Builtin builtin = GetWeakRefsNode.class.getAnnotation(Builtin.class);
2595+
return new BuiltinFunctionRootNode(l, builtin, WeakRefModuleBuiltinsFactory.GetWeakRefsNodeFactory.getInstance(), true);
2596+
}, GetWeakRefsNode.class, WeakRefModuleBuiltinsFactory.class);
25962597
setAttribute(__WEAKREF__, callTarget, pythonClass);
25972598
}
25982599

0 commit comments

Comments
 (0)