chaimleib/intervaltree

slow when using unique keys as data

Opened this issue · 0 comments

We noticed that a significant performance improvement to the tree.add(interval) method can be made by commenting out the following line from interval.py:

    def __eq__(self, other):
        """
        Whether the begins equal, the ends equal, and the data fields
        equal. Compare range_matches().
        :param other: Interval
        :return: True or False
        :rtype: bool
        """
        return (
            self.begin == other.begin and
            self.end == other.end # and
            # self.data == other.data
        )

If it is known that all data items are unique (in our case they are), perhaps a parameter for --unique_data would be useful? Happy to include a PR