Commit 487809e
committed
perf: use
Replace `any(d == -1 for d in shape)` with `-1 in shape`. The latter is
a C-level tuple containment, the former a Python-level generator.
On this machine (micro): 221 ns -> 45 ns per check.
End-to-end on the PR's repro (median of 3):
reshape(a.shape): 0.4 us -> 0.2 us (matches main; erases the regression
introduced by running the -1 check
unconditionally)
reshape((-1, K)): 2.7 us -> 2.3 us (small incremental win)
Pure readability / perf nit; semantics are identical since shape is
already a tuple of ints by the line above.-1 in shape for presence check in COO.reshape1 parent 71bbf2d commit 487809e
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1070 | 1070 | | |
1071 | 1071 | | |
1072 | 1072 | | |
1073 | | - | |
| 1073 | + | |
1074 | 1074 | | |
1075 | 1075 | | |
1076 | 1076 | | |
| |||
0 commit comments