Skip to content

add link on how to obtain GIL to guide #2897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion guide/src/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ an overview of their intended meaning, with examples when each type is best
used.


## Mutability and Rust types
## The Python GIL, mutability, and Rust types

Since Python has no concept of ownership, and works solely with boxed objects,
any Python object can be referenced any number of times, and mutation is allowed
Expand Down Expand Up @@ -43,6 +43,9 @@ an object's ownership has been passed to the Python interpreter, ensuring
references is done at runtime using `PyCell`, a scheme very similar to
`std::cell::RefCell`.

### Accessing the Python GIL

To get hold of a `Python<'py>` token to prove the GIL is held, consult [PyO3's documentation][obtaining-py].

## Object types

Expand Down Expand Up @@ -299,3 +302,4 @@ This trait marks structs that mirror native Python types, such as `PyList`.
[PyAny]: {{#PYO3_DOCS_URL}}/pyo3/types/struct.PyAny.html
[PyList_append]: {{#PYO3_DOCS_URL}}/pyo3/types/struct.PyList.html#method.append
[RefCell]: https://doc.rust-lang.org/std/cell/struct.RefCell.html
[obtaining-py]: {{#PYO3_DOCS_URL}}/pyo3/marker/struct.Python.html#obtaining-a-python-token