Using a dictionary comprehension to build a dictionary where every key maps to the exact same constant value e.g., {k: 1 for k in
keys}
is less efficient and less idiomatic than using the dict.fromkeys()
class method. dict.fromkeys()
is
specifically designed for this use case and offers better performance, especially for large iterables, as it avoids the overhead of creating and
processing individual key-value pairs in a comprehension.