Skip to content

Commit 9518e0b

Browse files
ehgusdstansby
andauthored
Increase speed of Delta encoding using np.subtract (#584)
* Use inplace subtract in Delta encoding * ruff reformatting * Add a comment explaining use of `subtract` for speed --------- Co-authored-by: David Stansby <[email protected]>
1 parent e836f39 commit 9518e0b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

numcodecs/delta.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ def encode(self, buf):
6363
enc[0] = arr[0]
6464

6565
# compute differences
66-
enc[1:] = np.diff(arr)
66+
# using np.subtract for in-place operations
67+
np.subtract(arr[1:], arr[0:-1], out=enc[1:])
6768

6869
return enc
6970

0 commit comments

Comments
 (0)