Minor update

This commit is contained in:
Miroslav Stampar
2021-05-19 18:20:39 +02:00
parent 35e575c287
commit 452915ed4a
5 changed files with 30 additions and 8 deletions

View File

@@ -56,6 +56,12 @@ class BigArray(list):
>>> _[20] = 0
>>> _[99999]
99999
>>> _ += [0]
>>> _[100000]
0
>>> _ = _ + [1]
>>> _[-1]
1
"""
def __init__(self, items=None):
@@ -69,6 +75,20 @@ class BigArray(list):
for item in (items or []):
self.append(item)
def __add__(self, value):
retval = BigArray(self)
for _ in value:
retval.append(_)
return retval
def __iadd__(self, value):
for _ in value:
self.append(_)
return self
def append(self, value):
self.chunks[-1].append(value)
@@ -145,7 +165,7 @@ class BigArray(list):
self.chunks, self.filenames = state
def __getitem__(self, y):
if y < 0:
while y < 0:
y += len(self)
index = y // self.chunk_length