Skip to content

Commit

Permalink
Add more docs to locked_for_each
Browse files Browse the repository at this point in the history
  • Loading branch information
bschoenmaeckers committed Oct 22, 2024
1 parent cb07a8f commit b42e7df
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/types/dict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ pub trait PyDictMethods<'py>: crate::sealed::Sealed {
/// This is useful when the GIL is disabled and the dictionary is shared between threads.
/// It is not guaranteed that the dictionary will not be modified during iteration when the
/// closure calls arbitrary Python code that releases the current critical section.
///
/// This method is a small performance optimization over `.iter().try_for_each()` when the
/// nightly feature is not enabled because we cannot implement an optimised version of
/// `iter().try_fold()` on stable yet. If your iteration is infallible then this method has the
/// same performance as `.iter().for_each()`.
fn locked_for_each<F>(&self, closure: F) -> PyResult<()>
where
F: Fn(Bound<'py, PyAny>, Bound<'py, PyAny>) -> PyResult<()>;
Expand Down

0 comments on commit b42e7df

Please sign in to comment.