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

Method hash

crates/vm/src/builtins/complex.rs:434–445  ·  view source on GitHub ↗
(zelf: &Py<Self>, _vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

432impl Hashable for PyComplex {
433 #[inline]
434 fn hash(zelf: &Py<Self>, _vm: &VirtualMachine) -> PyResult<hash::PyHash> {
435 let value = zelf.value;
436
437 let re_hash =
438 hash::hash_float(value.re).unwrap_or_else(|| hash::hash_object_id(zelf.get_id()));
439
440 let im_hash =
441 hash::hash_float(value.im).unwrap_or_else(|| hash::hash_object_id(zelf.get_id()));
442
443 let Wrapping(ret) = Wrapping(re_hash) + Wrapping(im_hash) * Wrapping(hash::IMAG);
444 Ok(hash::fix_sentinel(ret))
445 }
446}
447
448impl AsNumber for PyComplex {

Callers

nothing calls this directly

Calls 4

hash_floatFunction · 0.85
hash_object_idFunction · 0.85
fix_sentinelFunction · 0.85
get_idMethod · 0.45

Tested by

no test coverage detected