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

Method can_specialize_call

crates/vm/src/builtins/function.rs:653–660  ·  view source on GitHub ↗

Check if this function is eligible for exact-args call specialization. Returns true if: CO_OPTIMIZED, no VARARGS, no VARKEYWORDS, no kwonly args, and effective_nargs matches co_argcount.

(&self, effective_nargs: u32)

Source from the content-addressed store, hash-verified

651 /// Returns true if: CO_OPTIMIZED, no VARARGS, no VARKEYWORDS, no kwonly args,
652 /// and effective_nargs matches co_argcount.
653 pub(crate) fn can_specialize_call(&self, effective_nargs: u32) -> bool {
654 let code: &Py<PyCode> = &self.code;
655 let flags = code.flags;
656 flags.contains(bytecode::CodeFlags::OPTIMIZED)
657 && !flags.intersects(bytecode::CodeFlags::VARARGS | bytecode::CodeFlags::VARKEYWORDS)
658 && code.kwonlyarg_count == 0
659 && code.arg_count == effective_nargs
660 }
661
662 /// Runtime guard for CALL_*_EXACT_ARGS specialization: check only argcount.
663 /// Other invariants are guaranteed by function versioning and specialization-time checks.

Callers 4

execute_instructionMethod · 0.80
specialize_load_attrMethod · 0.80
specialize_binary_opMethod · 0.80
specialize_callMethod · 0.80

Calls 1

containsMethod · 0.45

Tested by

no test coverage detected