Skip to content

Commit

Permalink
basic support for slice operator
Browse files Browse the repository at this point in the history
  • Loading branch information
relleums committed Jun 18, 2024
1 parent 569313d commit a1c75ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions dynamicsizerecarray/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ def _grow_if_needed(self, additional_size):
del swp

def _raise_IndexError_if_out_of_bounds(self, idx):
if isinstance(idx, slice):
if idx.start:
self.__raise_IndexError_if_out_of_bounds(idx=idx.start)
if idx.stop:
self.__raise_IndexError_if_out_of_bounds(idx=idx.stop)
else:
self.__raise_IndexError_if_out_of_bounds(idx=idx)

def __raise_IndexError_if_out_of_bounds(self, idx):
if idx >= self._size:
raise IndexError(
"index {:d} is out of bounds for size {:d}".format(
Expand Down
2 changes: 1 addition & 1 deletion dynamicsizerecarray/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.3"
__version__ = "0.0.4"

0 comments on commit a1c75ec

Please sign in to comment.