Commit 76a03b3
Benjamin Moody
_rd_dat_signals: optimize construction of expanded arrays.
When reading signal data with smooth_frames = False, we want to return
a one-dimensional array of samples for each signal, which means
extracting a range of samples from each frame and concatenating those
ranges into a single numpy array.
Previously this was done by constructing an array of all the desired
sample indices, and using that array as a subscript into the input
sig_data array. This is inefficient in both time and memory.
Instead, extract the desired samples as a slice of a two-dimensional
array, and reshape that slice to obtain a 1D array.
(Using reshape(-1) instead of flatten() means that if samps_per_frame
is 1, the array does not need to be copied. If the array does need to
be copied, the reshape operation is still faster than any Python loop
and doesn't require additional memory.)1 parent 5bb2e3c commit 76a03b3
1 file changed
+6
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1193 | 1193 | | |
1194 | 1194 | | |
1195 | 1195 | | |
| 1196 | + | |
| 1197 | + | |
1196 | 1198 | | |
1197 | | - | |
1198 | | - | |
1199 | | - | |
1200 | | - | |
1201 | | - | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
1202 | 1203 | | |
1203 | 1204 | | |
1204 | 1205 | | |
| |||
0 commit comments