Closed jakelishman closed 6 months ago
Totals | |
---|---|
Change from base Build 7967150733: | 0.0% |
Covered Lines: | 16740 |
Relevant Lines: | 17335 |
@Mergifyio backport stable/0.14
backport stable/0.14
Thanks for writing this! I had a feeling we’d need to profile the function but I guess the fix was easier than we thought
Flipping the order of
Slice
andInt
inSliceOrInt
so thatInt
comes first means that theFromPyObject
derivation will then tryInt
first, which is the correct variant in like 99.9% of uses of the struct. This has the impact of improving int__getitem__
times in the custom iterators by about 3x (from 205ns to 61ns on my machine), which has knock-on effects for the implicit iterators Python defines for these classes.This implements the performance improvement I mentioned in https://github.com/Qiskit/rustworkx/issues/1090#issuecomment-1954836685. I can also look into defining manual Python-space iterators (rather than using the implicit one based on
__getitem__
), if that's an interesting path - I haven't tried it yet, so I don't know if there's more performance to be had.