Skip to content

Commit

Permalink
perf: implement append to avoid invalidating id2offset (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
alaeddine-13 authored Feb 3, 2022
1 parent 8db14ff commit 4c05919
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docarray/array/storage/memory/seqlike.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ def insert(self, index: int, value: 'Document'):
"""
self._data.insert(index, value)

def append(self, value: 'Document'):
"""Append `doc` to the end of the array.
:param value: The doc needs to be appended.
"""
self._data.append(value)
if not self._needs_id2offset_rebuild:
self._id_to_index[value.id] = len(self) - 1

def __eq__(self, other):
return (
type(self) is type(other)
Expand Down

0 comments on commit 4c05919

Please sign in to comment.