Skip to content

Commit f9dfae1

Browse files
committed
intrinsified python_cext PyFloat_XXX
1 parent 0b3589b commit f9dfae1

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2364,6 +2364,28 @@ Object fromString(VirtualFrame frame, String s, long base, @SuppressWarnings("un
23642364
}
23652365
}
23662366

2367+
///////////// float /////////////
2368+
2369+
@Builtin(name = "PyFloat_FromDouble", minNumOfPositionalArgs = 1)
2370+
@GenerateNodeFactory
2371+
abstract static class PyFloatFromDoubleNode extends PythonUnaryBuiltinNode {
2372+
2373+
@Specialization
2374+
double fromDouble(double d) {
2375+
return d;
2376+
}
2377+
2378+
@Specialization(guards = {"!isDouble(obj)"})
2379+
public Object fromDouble(VirtualFrame frame, Object obj,
2380+
@SuppressWarnings("unused") @Cached GetClassNode getClassNode,
2381+
@SuppressWarnings("unused") @Cached IsSubtypeNode isSubtypeNode,
2382+
@Cached StrNode strNode,
2383+
@Cached PRaiseNativeNode raiseNativeNode) {
2384+
// cpython PyFloat_FromDouble takes only 'double'
2385+
return raiseNativeNode.raiseInt(frame, -1, SystemError, BAD_ARG_TO_INTERNAL_FUNC_WAS_S_P, strNode.executeWith(frame, obj), obj);
2386+
}
2387+
}
2388+
23672389
/**
23682390
* This is used in the ExternalFunctionNode below, so all arguments passed from Python code into
23692391
* a C function are automatically unwrapped if they are wrapped. This function is also called

graalpython/lib-graalpython/python_cext.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,6 @@ def PyDictProxy_New(mapping):
6666
mappingproxy = type(type.__dict__)
6767
return mappingproxy(mapping)
6868

69-
##################### FLOAT
70-
71-
@may_raise
72-
def PyFloat_FromDouble(n):
73-
return float(n)
74-
75-
7669
##################### COMPLEX
7770

7871
@may_raise

0 commit comments

Comments
 (0)