Skip to content

Commit

Permalink
Add crate comment for py_ext.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhartman committed Nov 17, 2023
1 parent a39fe80 commit 0fda537
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/accelerate/src/quantum_circuit/py_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@
// Any modifications or derivative works of this code must retain this
// copyright notice, and modified files need to carry a notice indicating
// that they have been altered from the originals.
//! Contains helper functions for creating [Py<T>] (GIL-independent)
//! objects without creating an intermediate owned reference. These functions
//! are faster than PyO3's list and tuple factory methods when the caller
//! doesn't need to dereference the newly constructed object (i.e. if the
//! resulting [Py<T>] will simply be stored in a Rust struct).
//!
//! The reason this is faster is because PyO3 tracks owned references and
//! will perform deallocation when the active [GILPool] goes out of scope.
//! If we don't need to dereference the [Py<T>], then we can skip the
//! tracking and deallocation.

use pyo3::ffi::Py_ssize_t;
use pyo3::prelude::*;
use pyo3::types::{PyList, PyTuple};
Expand Down

0 comments on commit 0fda537

Please sign in to comment.