Skip to content

Commit 4b21689

Browse files
committed
perf: optimize document getter
1 parent 6b07992 commit 4b21689

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

docarray/array/storage/base/seqlike.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ def insert(self, index: int, value: 'Document'):
1313
:param index: Position of the insertion.
1414
:param value: The doc needs to be inserted.
1515
"""
16-
self._set_doc_by_id(None, value)
16+
self._set_doc_by_id(value.id, value)
1717
self._offset2ids.insert(index, value.id)
1818

1919
def append(self, value: 'Document'):
2020
"""Append `doc` to the end of the array.
2121
2222
:param value: The doc needs to be appended.
2323
"""
24-
self._set_doc_by_id(None, value)
24+
self._set_doc_by_id(value.id, value)
2525
self._offset2ids.append(value.id)
2626

2727
@abstractmethod

docarray/array/storage/memory/getsetdel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def _del_doc_by_id(self, _id: str):
1717

1818
def _set_doc_by_id(self, _id: str, value: 'Document'):
1919
_vid = value.id
20-
if _id is not None and _id != _vid:
20+
if _id != _vid:
2121
del self._data[_id]
2222
self._data[_vid] = value
2323

0 commit comments

Comments
 (0)