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

Method get_version_for_current_state

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

Returns the current version, assigning a fresh one if previously invalidated. Returns 0 if the version counter has overflowed. `_PyFunction_GetVersionForCurrentState`

(&self)

Source from the content-addressed store, hash-verified

625 /// Returns 0 if the version counter has overflowed.
626 /// `_PyFunction_GetVersionForCurrentState`
627 pub fn get_version_for_current_state(&self) -> u32 {
628 let v = self.func_version.load(Relaxed);
629 if v != 0 {
630 return v;
631 }
632 let new_v = next_func_version();
633 if new_v == 0 {
634 return 0;
635 }
636 self.func_version.store(new_v, Relaxed);
637 new_v
638 }
639
640 /// function_kind(SIMPLE_FUNCTION) equivalent for CALL specialization.
641 /// Returns true if: CO_OPTIMIZED, no VARARGS, no VARKEYWORDS, no kwonly args.

Callers 4

specialize_load_attrMethod · 0.80
specialize_callMethod · 0.80
specialize_call_kwMethod · 0.80

Calls 3

next_func_versionFunction · 0.85
loadMethod · 0.45
storeMethod · 0.45

Tested by

no test coverage detected