Currently a lot of methods will check bit ranges and throw exceptions for out of range positions.
Basically I'm thinking of anything that uses the _validate_slice method.
Standard slice checking doesn't do this - if an index is out of range it gets clipped to the extreme instead. By using this behaviour we can simplify some code and perhaps also be more Pythonic.
It's a breaking change, but not hugely so - some exceptions wouldn't be raised.
Validating a slice could then be done with just this:
i = slice(start, end, None).indices(len(self))
return i[0], i[1]
Currently a lot of methods will check bit ranges and throw exceptions for out of range positions.
Basically I'm thinking of anything that uses the
_validate_slice
method.Standard slice checking doesn't do this - if an index is out of range it gets clipped to the extreme instead. By using this behaviour we can simplify some code and perhaps also be more Pythonic.
It's a breaking change, but not hugely so - some exceptions wouldn't be raised.
Validating a slice could then be done with just this: