Steve Jorgensen wrote:
Christopher Barker wrote:
On Sat, Feb 29, 2020 at 4:37 AM Alex Hall firstname.lastname@example.org wrote: It seems like most of this would be very easy to implement yourself with the exact semantics that you prefer and find most intuitive, while other people might have different expectations. I have to agree here. You are proposing that a slice object be treated as a general purpose interval, but that is not, in fact what they are. This is made clear by: " Presumably, these operations would raise exceptions when used with slices that have step values other than None." and also: "whereas a slice represents a possibly continuous range of any kind of value to which magnitude is applicable." well, sort of. Given the implementation and duck typing, I suppose that's true. But in fact, slices were designed for, and are (at least mostly) used to, well, slice sequences, which are always integer indexes, and hav semantics specific to that use case: <snip>OK. That does make sense to me.
In that case, I still do think that this kind of functionality is of enough general use to have something for it in the Python standard library, though it should probably be through the introduction of a new type (possibly named something like "bounds") since neither range nor slice is really a good fit. I'm thinking it should/would be much more limited in scope than intervaltree (which does look really nice).