Add Rust implementation of core interval operations for performance#105
Closed
avaitla wants to merge 1 commit intoAlexandreDecan:masterfrom
Closed
Add Rust implementation of core interval operations for performance#105avaitla wants to merge 1 commit intoAlexandreDecan:masterfrom
avaitla wants to merge 1 commit intoAlexandreDecan:masterfrom
Conversation
This adds a high-performance Rust backend for portion that can be used to speed up interval operations by 10-1000x depending on the operation. Key changes: - rust_core/: PyO3-based Rust implementation of Interval operations - BoundType enum (Closed/Open) - Value enum (NegInf/Finite/PosInf) - Atomic struct for single intervals - Interval struct for union of atomic intervals - All core operations: union, intersection, complement, difference - Python bindings with RustInterval and helper functions - benchmark.py: Performance comparison script showing speedups: - Interval creation: 22-40x faster - Intersection: 850-1100x faster - Union: 9-42x faster - Complement: 430-800x faster - Containment checks: 12-15x faster - Difference: 740-1090x faster - Real-world mixed operations: 50-52x faster Build and install with: cd rust_core && maturin build --release pip install target/wheels/*.whl Usage: import portion_rust as PR interval = PR.rust_closed(0, 10) | PR.rust_closed(20, 30)
Owner
|
Any human comment on this? |
Author
|
Thanks for the work on this it's very useful for us. Apologies it was a mistake to open this PR back to the main repo. We use this library but have a lot of intervals and found the bottleneck to be here. I've been implementing in rust we only need date time intervals and didn't mean to make a pr back into main branch. |
Owner
|
Thanks for the reply! I'm sorry it took me so long to answer, I don't know why, but I received not notification for your answer :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a high-performance Rust backend for portion that can be used to speed up interval operations by 10-1000x depending on the operation.
Key changes:
rust_core/: PyO3-based Rust implementation of Interval operations
benchmark.py: Performance comparison script showing speedups:
Build and install with:
cd rust_core && maturin build --release
pip install target/wheels/*.whl
Usage:
import portion_rust as PR
interval = PR.rust_closed(0, 10) | PR.rust_closed(20, 30)