Skip to content

Conversation

@egormanga
Copy link

  • Using dict.setdefault() is much faster than doing a separate dict.__contains__() check each iteration. This gives us ~1/6× better performance.
  • But keeping the in-place addition and falling back by catching KeyError gives another 1/6 over using dict.get().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant