Skip to content

Commit

Permalink
Integrate #66
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreDecan committed Sep 12, 2021
1 parent ca7d791 commit 70d3459
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
* Use `self.__class__` instead of `Interval` to create new instances;
* Deprecate and move `mergeable` function to `Interval._mergeable` class method;
* `Interval.from_atomic` is now a class method instead of a static method.
- Speed up lookups in `IntervalDict` ([#65](https://github.com/AlexandreDecan/portion/issues/58), Jeff Trull).
- Speed up lookups in `IntervalDict` ([#65](https://github.com/AlexandreDecan/portion/issues/65), Jeff Trull).
- Speed up intersection for non-overlapping intervals ([#66](https://github.com/AlexandreDecan/portion/issues/66), Jeff Trull).



## 2.1.6 (2021-04-17)
Expand Down
7 changes: 3 additions & 4 deletions portion/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,9 @@ def __and__(self, other):
if not isinstance(other, Interval):
return NotImplemented

if (self.upper < other.lower) or (self.lower > other.upper):
# early out for non-overlapping intervals
intersections = []
return self.__class__(*intersections)
if self.upper < other.lower or self.lower > other.upper:
# Early out for non-overlapping intervals
return self.__class__()
elif self.atomic and other.atomic:
if self.lower == other.lower:
lower = self.lower
Expand Down

0 comments on commit 70d3459

Please sign in to comment.