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

Method set_inner

crates/stdlib/src/contextvars.rs:344–359  ·  view source on GitHub ↗

contextvar_set in CPython

(zelf: &Py<Self>, value: PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

342
343 // contextvar_set in CPython
344 fn set_inner(zelf: &Py<Self>, value: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> {
345 let ctx = PyContext::current(vm);
346
347 let mut vars = ctx.borrow_vars_mut();
348 vars.insert(zelf.to_owned(), value.clone());
349
350 zelf.cached_id.store(ctx.get_id(), Ordering::SeqCst);
351
352 let cache = ContextVarCache {
353 object: value,
354 idx: ctx.inner.idx.get(),
355 };
356 zelf.cached.store(Some(cache));
357
358 Ok(())
359 }
360
361 fn generate_hash(zelf: &Py<Self>, vm: &VirtualMachine) -> PyHash {
362 let name_hash = vm.state.hash_secret.hash_str(&zelf.name);

Callers

nothing calls this directly

Calls 8

borrow_vars_mutMethod · 0.80
SomeClass · 0.50
insertMethod · 0.45
to_ownedMethod · 0.45
cloneMethod · 0.45
storeMethod · 0.45
get_idMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected