-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add manual iterator implementations for custom vec iterables (#1107)
* Add manual iterator implementations for custom vec iterables This adds manual `Iterator` implementors for the custom vec `Iterable` pyclasses, which were previously using the Python default iterator implementation that attempts calls to `__getitem__` with successive integers until an `IndexError` is raised. Doing this means that we no longer have any overhead from converting Python-space integer indices to Rust-space ones, because we just store a pointer to the backing vec internally and yield from that using an index we track ourselves. * Add release note * Remove `__len__` from custom iterators This matches the Python behaviour for the implicit sequence-protocol iterators; they have only `__length_hint__` and not `__len__`. * Add reversed iterators * Add explicit tests * Fixup release note
- Loading branch information
1 parent
a9d8686
commit bf3f703
Showing
4 changed files
with
189 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
features: | ||
- | | ||
Rustworkx functions that return custom iterable objects, such as | ||
:meth:`.PyDiGraph.node_indices`, now each have an associated custom | ||
iterator and reversed-iterator object for these. This provides a speedup | ||
of approximately 40% for iterating through the custom iterables. | ||
These types are not directly nameable or constructable from Python space, and other than the | ||
performance improvement, the behavior should largely not be noticable from Python space. |
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
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