
July 29, 2020
1:26 a.m.
Christopher Barker writes:
from itertools import islice
smaller_dict = dict(islice(large_dict.items(), 0, 255))
which works, and isn't doing an unnecessary copying but it's pretty darn ugly, as far as I'm concerned.
In your application, I think that's just pretty, myself. The only thing that's missing is slice notation. But that's probably not hard to implement in terms of the islice function, just completely redundant.