Skip to content

Commit c9b9a64

Browse files
committed
Improve inlining of method constructor.
1 parent 12c1d44 commit c9b9a64

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,7 @@ public Object generator(Object args, Object kwargs) {
18011801

18021802
@Builtin(name = "method", fixedNumOfPositionalArgs = 3, constructsClass = {PythonBuiltinClassType.PMethod}, isPublic = false)
18031803
@GenerateNodeFactory
1804-
public abstract static class MethodTypeNode extends PythonBuiltinNode {
1804+
public abstract static class MethodTypeNode extends PythonTernaryBuiltinNode {
18051805
@Specialization
18061806
Object method(PythonClass cls, Object self, PFunction func) {
18071807
return factory().createMethod(cls, self, func);

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,14 @@ synchronized public Object doIt(PFunction func) {
13941394
* declare the module argument
13951395
*/
13961396
builtinFunc = func;
1397+
func.getFunctionRootNode().accept(new NodeVisitor() {
1398+
public boolean visit(Node node) {
1399+
if (node instanceof PythonCallNode) {
1400+
node.replace(((PythonCallNode) node).asSpecialCall());
1401+
}
1402+
return true;
1403+
}
1404+
});
13971405
} else {
13981406
/*
13991407
* Otherwise, we create a new function with an arity that requires one extra

graalpython/lib-graalpython/classmethod.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class classmethod(object):
4343
def __init__(self, func):
4444
self.__func__ = func
4545

46+
@__builtin__
4647
def __get__(self, instance, owner=None):
4748
if owner is None:
4849
return classmethod.method(type(instance), self.__func__)

0 commit comments

Comments
 (0)