Skip to content

Commit b106ce5

Browse files
committed
add os.cpu_count()
1 parent fae3004 commit b106ce5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,4 +1531,13 @@ protected String doGeneric(Object x) {
15311531
return recursive.execute(strNode.executeWith(PythonBuiltinClassType.PString, x, PNone.NO_VALUE, PNone.NO_VALUE));
15321532
}
15331533
}
1534+
1535+
@Builtin(name = "cpu_count", fixedNumOfPositionalArgs = 0)
1536+
@GenerateNodeFactory
1537+
abstract static class CpuCountNode extends PythonBuiltinNode {
1538+
@Specialization
1539+
int getCpuCount() {
1540+
return Runtime.getRuntime().availableProcessors();
1541+
}
1542+
}
15341543
}

0 commit comments

Comments
 (0)