Skip to content

Commit 8886403

Browse files
committed
Implement int.as_integer_ratio
1 parent 69dbbe0 commit 8886403

File tree

1 file changed

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

1 file changed

+9
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,6 +2457,15 @@ int get(@SuppressWarnings("unused") Object self) {
24572457
}
24582458
}
24592459

2460+
@GenerateNodeFactory
2461+
@Builtin(name = "as_integer_ratio", minNumOfPositionalArgs = 1, doc = "Return integer ratio.")
2462+
abstract static class AsIntegerRatioNode extends PythonBuiltinNode {
2463+
@Specialization
2464+
Object get(VirtualFrame frame, Object self, @Cached IntNode intNode) {
2465+
return factory().createTuple(new Object[]{intNode.execute(frame, self), 1});
2466+
}
2467+
}
2468+
24602469
@GenerateNodeFactory
24612470
@Builtin(name = SpecialMethodNames.__TRUNC__, minNumOfPositionalArgs = 1, doc = "Truncating an Integral returns itself.")
24622471
abstract static class TruncNode extends IntNode {

0 commit comments

Comments
 (0)