[mlir][python] Directly implement sequence protocol on Sliceable.
* While annoying, this is the only way to get C++ exception handling out of the happy path for normal iteration. * Implements sq_length and sq_item for the sequence protocol (used for iteration, including list() construction). * Implements mp_subscript for general use (i.e. foo[1] and foo[1:1]). * For constructing a `list(op.results)`, this reduces the time from ~4-5us to ~1.5us on my machine (give or take measurement overhead) and eliminates C++ exceptions, which is a worthy goal in itself. * Compared to a baseline of similar construction of a three-integer list, which takes 450ns (might just be measuring function call overhead). * See issue discussed on the pybind side: https://github.com/pybind/pybind11/issues/2842 Differential Revision: https://reviews.llvm.org/D119691
Loading
Please sign in to comment