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

Interesting... I wonder if this is vulnerable to getting garbaged collected at any point during execution.
No, the __next__ slot wrapper holds a reference to its associated count object.