Possible micro-op for edge_count(), though the sum() comprehension would become slightly less descriptive. Do let me know your thoughts on this.
x = {a:str(a) for a in range(100)}
%timeit sum(len(y) for y in x.values())
2.71 μs ± 11.7 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)
%timeit sum(map(len, x.values()))
1.27 μs ± 4.85 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)
Possible micro-op for
edge_count()
, though the sum() comprehension would become slightly less descriptive. Do let me know your thoughts on this.