It's common to initialize mutable collections (dict, list) without elements, with the intention to mutate it later.
Rust approach this with constructors like BinaryHeap::new, Vec::new, or even iter::empty.
Python approach this with None checks in list, dict, set, etc... at runtime (or empty tuples as argument, need to check).
The former allow maximal performance and clarity of intent, while the second is the most convenient to type (and since dict and list can be written as literals, CPython can optimize this under the hood, bypassing the potential performance trade-off).
EDIT: see advancements on this issue on the comment below
It's common to initialize mutable collections (
dict,list) without elements, with the intention to mutate it later.Rust approach this with constructors like
BinaryHeap::new,Vec::new, or eveniter::empty.Python approach this with None checks in list, dict, set, etc... at runtime (or empty tuples as argument, need to check).
The former allow maximal performance and clarity of intent, while the second is the most convenient to type (and since
dictandlistcan be written as literals, CPython can optimize this under the hood, bypassing the potential performance trade-off).EDIT: see advancements on this issue on the comment below
MyCollection([])calls.