MCPcopy Index your code
hub / github.com/RustPython/RustPython / oct

Function oct

crates/vm/src/stdlib/builtins.rs:918–928  ·  view source on GitHub ↗
(number: ArgIndex, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

916
917 #[pyfunction]
918 fn oct(number: ArgIndex, vm: &VirtualMachine) -> PyResult {
919 let number = number.into_int_ref();
920 let n = number.as_bigint();
921 let s = if n.is_negative() {
922 format!("-0o{:o}", n.abs())
923 } else {
924 format!("0o{n:o}")
925 };
926
927 Ok(vm.ctx.new_str(s).into())
928 }
929
930 #[pyfunction]
931 fn ord(string: Either<ArgBytesLike, PyStrRef>, vm: &VirtualMachine) -> PyResult<u32> {

Callers 10

test_umaskMethod · 0.85
__str__Method · 0.85
test_octMethod · 0.85
testUnaryOpsMethod · 0.85
test_creation_modeMethod · 0.85
test_cached_readonlyMethod · 0.85
stdlib_os.pyFile · 0.85

Calls 3

into_int_refMethod · 0.80
as_bigintMethod · 0.80
new_strMethod · 0.45

Tested by 9

test_umaskMethod · 0.68
__str__Method · 0.68
test_octMethod · 0.68
testUnaryOpsMethod · 0.68
test_creation_modeMethod · 0.68
test_cached_readonlyMethod · 0.68