Y
Hacker News
new
|
ask
|
show
|
jobs
by
klyrs
1877 days ago
Oh, this is nice. You can do it in one line (plus imports) with
d = defaultdict(count().__next__)
1 comments
scienceman
1877 days ago
Interesting... I wonder if this is vulnerable to getting garbaged collected at any point during execution.
link
klyrs
1877 days ago
No, the __next__ slot wrapper holds a reference to its associated count object.
link