Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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: pybind/pybind11#2842 Differential Revision: https://reviews.llvm.org/D119691
- Loading branch information
1 parent
e404e22
commit 429b0cf
Showing
2 changed files
with
85 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters