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

Function generic_alloc

crates/vm/src/builtins/object.rs:107–120  ·  view source on GitHub ↗
(cls: PyTypeRef, _nitems: usize, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

105}
106
107pub(crate) fn generic_alloc(cls: PyTypeRef, _nitems: usize, vm: &VirtualMachine) -> PyResult {
108 // Only create dict if the class has HAS_DICT flag (i.e., __slots__ was not defined
109 // or __dict__ is in __slots__)
110 let dict = if cls
111 .slots
112 .flags
113 .has_feature(crate::types::PyTypeFlags::HAS_DICT)
114 {
115 Some(vm.ctx.new_dict())
116 } else {
117 None
118 };
119 Ok(crate::PyRef::new_ref(PyBaseObject, cls, dict).into())
120}
121
122impl Initializer for PyBaseObject {
123 type Args = FuncArgs;

Callers 1

slot_newMethod · 0.85

Calls 3

has_featureMethod · 0.80
new_dictMethod · 0.80
SomeClass · 0.50

Tested by

no test coverage detected