pyo3/examples
Adam Reichold c5f9001985
Remove deferred reference count increments and make the global reference pool optional (#4095)
* Add feature controlling the global reference pool to enable avoiding its overhead.

* Document reference-pool feature in the performance guide.

* Invert semantics of feature to disable reference pool so the new behaviour becomes opt-in

* Remove delayed reference count increments as we cannot prevent reference count errors as long as these are available

* Adjust tests to be compatible with disable-reference-pool feature

* Adjust tests to be compatible with py-clone feature

* Adjust the GIL benchmark to the updated reference pool semantics.

* Further extend and clarify the documentation of the py-clone and disable-reference-pool features

* Replace disable-reference-pool feature by pyo3_disable_reference_pool conditional compilation flag

Such a flag is harder to use and thereby also harder to abuse. This seems
appropriate as this is purely a performance-oriented change which show only be
enabled by leaf crates and brings with it additional highly implicit sources of
process aborts.

* Add pyo3_leak_on_drop_without_reference_pool to turn aborts into leaks when the global reference pool is disabled and the GIL is not held
2024-05-11 14:48:45 +00:00
..
decorator release notes for 0.21.2 (#4091) 2024-04-18 08:59:02 +00:00
getitem Change the types of `PySliceIndices` and `PySlice::indices (#3761) 2024-04-18 07:33:07 +00:00
maturin-starter release notes for 0.21.2 (#4091) 2024-04-18 08:59:02 +00:00
plugin release notes for 0.21.2 (#4091) 2024-04-18 08:59:02 +00:00
sequential Create subinterpreter example 2023-11-26 09:49:56 +00:00
setuptools-rust-starter release notes for 0.21.2 (#4091) 2024-04-18 08:59:02 +00:00
string-sum Merge pull request #3536 from davidhewitt/maturin-build-args 2023-10-29 13:27:15 +00:00
word-count release notes for 0.21.2 (#4091) 2024-04-18 08:59:02 +00:00
Cargo.toml Remove deferred reference count increments and make the global reference pool optional (#4095) 2024-05-11 14:48:45 +00:00
README.md Create subinterpreter example 2023-11-26 09:49:56 +00:00

README.md

PyO3 Examples

These example crates are a collection of toy extension modules built with PyO3. They are all tested using nox in PyO3's CI.

Below is a brief description of each of these:

Example Description
decorator A project showcasing the example from the Emulating callable objects chapter of the guide.
maturin-starter A template project which is configured to use maturin for development.
setuptools-rust-starter A template project which is configured to use setuptools_rust for development.
word-count A quick performance comparison between word counter implementations written in each of Rust and Python.
plugin Illustrates how to use Python as a scripting language within a Rust application
sequential Illustrates how to use pyo3-ffi to write subinterpreter-safe modules

Creating new projects from these examples

To copy an example, use cargo-generate. Follow the commands below, replacing <example> with the example to start from:

$ cargo install cargo-generate
$ cargo generate --git https://github.com/PyO3/pyo3 examples/<example>

(cargo generate will take a little while to clone the PyO3 repo first; be patient when waiting for the command to run.)