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

Function reversed

crates/vm/src/stdlib/builtins.rs:1028–1039  ·  view source on GitHub ↗
(obj: PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

1026
1027 #[pyfunction]
1028 pub fn reversed(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult {
1029 if let Some(reversed_method) = vm.get_method(obj.clone(), identifier!(vm, __reversed__)) {
1030 reversed_method?.call((), vm)
1031 } else {
1032 vm.get_method_or_type_error(obj.clone(), identifier!(vm, __getitem__), || {
1033 "argument to reversed() must be a sequence".to_owned()
1034 })?;
1035 let len = obj.length(vm)?;
1036 let obj_iterator = PyReverseSequenceIterator::new(obj, len);
1037 Ok(obj_iterator.into_pyobject(vm))
1038 }
1039 }
1040
1041 #[derive(FromArgs)]
1042 pub struct RoundArgs {

Callers 15

_c3_mroFunction · 0.85
walkFunction · 0.85
compiler_fixupFunction · 0.85
visit_AttributeMethod · 0.85
_shutdownFunction · 0.85
formatMethod · 0.85
__reversed__Method · 0.85
isreservedFunction · 0.85
_getmemberMethod · 0.85
heapifyFunction · 0.85
heapify_maxFunction · 0.85
shuffleMethod · 0.85

Calls 8

newFunction · 0.85
get_methodMethod · 0.45
cloneMethod · 0.45
callMethod · 0.45
to_ownedMethod · 0.45
lengthMethod · 0.45
into_pyobjectMethod · 0.45

Tested by 15

test_basicsMethod · 0.68
test_extendleftMethod · 0.68
test_reverseMethod · 0.68
test_big_stack_rightMethod · 0.68
test_big_stack_leftMethod · 0.68
test_reversedMethod · 0.68
test_reversed_newMethod · 0.68
test_basicsMethod · 0.68
test_objecttypesMethod · 0.68
test_invariantMethod · 0.68