Skip to content

Commit c4636a1

Browse files
author
Vincent Moens
committed
[Performance] Remove list against list check during set
ghstack-source-id: 9fb608e Pull Request resolved: #954
1 parent dd80ecc commit c4636a1

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

tensordict/_td.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2254,18 +2254,16 @@ def _set_at_str(self, key, value, idx, *, validated, non_blocking: bool):
22542254

22552255
if is_non_tensor(value) and not (self._is_shared or self._is_memmap):
22562256
dest = tensor_in
2257-
is_diff = dest[idx].tolist() != value.tolist()
2258-
if is_diff:
2259-
dest_val = dest.maybe_to_stack()
2260-
dest_val[idx] = value
2261-
if dest_val is not dest:
2262-
self._set_str(
2263-
key,
2264-
dest_val,
2265-
validated=True,
2266-
inplace=False,
2267-
ignore_lock=True,
2268-
)
2257+
dest_val = dest.maybe_to_stack()
2258+
dest_val[idx] = value
2259+
if dest_val is not dest:
2260+
self._set_str(
2261+
key,
2262+
dest_val,
2263+
validated=True,
2264+
inplace=False,
2265+
ignore_lock=True,
2266+
)
22692267
return
22702268

22712269
if isinstance(idx, tuple) and len(idx) and isinstance(idx[0], tuple):

0 commit comments

Comments
 (0)