Skip to content

Commit ce4b52a

Browse files
committed
comment and upd CHANGELOG
1 parent 7fd3e7d commit ce4b52a

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Version 3.0.0
44
- Dropped support for Python 2.6, 3.2, and 3.3
55
- Add support for Python 3.5 and 3.6
6+
- Faster `Interval` overlap checking (@tuxzz, #56)
67
- Updated README:
78
- new restructuring methods from 2.1.0
89
- example of `from_tuples()` added

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ Version 3.0.0
372372

373373
- Dropped support for Python 2.6, 3.2, and 3.3
374374
- Add support for Python 3.5 and 3.6
375+
- Faster ``Interval`` overlap checking (@tuxzz, #56)
375376
- Updated README:
376377

377378
- new restructuring methods from 2.1.0

intervaltree/interval.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ def overlaps(self, begin, end=None):
3939
:rtype: bool
4040
"""
4141
if end is not None:
42+
# An overlap means that some C exists that is inside both ranges:
43+
# begin <= C < end
44+
# and
45+
# self.begin <= C < self.end
46+
# See https://stackoverflow.com/questions/3269434/whats-the-most-efficient-way-to-test-two-integer-ranges-for-overlap/3269471#3269471
4247
return begin < self.end and end > self.begin
4348
try:
4449
return self.overlaps(begin.begin, begin.end)

0 commit comments

Comments
 (0)