Skip to content

Commit

Permalink
Add note about the GIL preventing parallelism
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoldbaum committed Dec 11, 2024
1 parent a5ace87 commit b71acef
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions guide/src/parallelism.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ In the example below, we share a `Vec` of User ID objects defined using the
`pyclass` macro and spawn threads to process the collection of data into a `Vec`
of booleans based on a predicate using a rayon parallel iterator:

* Note: This example is meant to illustrate how to drop and re-acquire the GIL
to avoid creating deadlocks. Unless the spawned threads subsequently
release the GIL or you are using the free-threaded build of CPython, you
will not see any speedups due to multi-threaded parallelism using `rayon`
to parallelize code that acquires the GIL.

```rust,no_run
use pyo3::prelude::*;
Expand Down

0 comments on commit b71acef

Please sign in to comment.