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

Quadratic performance characteristics #23

Open
avikivity opened this issue May 30, 2016 · 2 comments
Open

Quadratic performance characteristics #23

avikivity opened this issue May 30, 2016 · 2 comments

Comments

@avikivity
Copy link

pyinter is incredibly slow; adding a thousand intervals requires a million operations, because add() loops over all the existing elements in the set.

add() (and similar functions) should take advantage of the sorted order and only touch elements which intersect other.

@intiocean
Copy link
Owner

I agree @avikivity – It's never been optimised for large sets of intervals. A PR to improve this would be very appreciated as I won't have time to do this at the moment.

@ilius
Copy link

ilius commented Aug 16, 2016

Also intersection takes O(M*N) running time (the easiest way to implement). This operation was the only reason I looked up for an interval set library.
Here is my simple (but a little messy) code with O(M+N) running time: https://github.com/ilius/starcal/blob/master/scal3/interval_utils.py#L70

My only problem is handling open/closed boundaries properly

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

No branches or pull requests

3 participants