Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster union find #415

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

markopy
Copy link
Contributor

@markopy markopy commented Oct 3, 2020

This speeds up single_linkage by about two orders of magnitude by using direct array access in fast_find which Cython can compile into a pure C loop.

I saw in the commit history that this was attempted before but abandoned due to unexplained crashes. The reason is that the current code is actually buggy and only works because python's wraparound indexing hides the problem. When using raw pointer access the bug leads to heap corruption and subsequent random crashes. A simple check to only label if we are not at the root already fixes this.

Also fixes #321 which should further improve overall performance.

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.

Possible improvement to path compression runtime
1 participant