pyo3
pyo3 copied to clipboard
Rust bindings for the Python interpreter
### Bug Description Python's `exec()` has `__name__` set to `__main__`: ```python exec("print(__name__)") ``` ``` __main__ ``` When running the same code through PyO3's `py.run()`, it'll give `builtins`. ### Steps to...
This allows to control objects initialization flow in the Rust code in case of inheritance from native Python types. A simple example, you implement a class inherited from `PyDict` but...
This PR introduces the capability to inherit from classes where the exact layout/size is not known using the mechanism described in [PEP 697](https://peps.python.org/pep-0697/). This allows inheriting from `type` in order...
Before this change, classes inheriting the base object were constructed by using `TP_ALLOC` directly, obscuring the intention of `PyNativeTypeInitializer`, and inheriting from other base classes requires use of the unlimited...
Hi, I am currently developing a crate that export a generic function that is meant to be configured by users at compile time before being exported to python. This looks...
If `PyImport_ExecCodeModuleEx` is called with an empty filename or module name, references to any Python variables defined in this context may break assumptions in standard library code. Notably, if `inspect.stack()`...
This PR adds all definitions from `pythread.h` and `cpython/pythread.h` that haven't been deprecated or removed as of CPython 3.13. Of the functions, some are fully documented, some are undocumented but...
Closes #4887. This PR adds IntoPyObject and FromPyObject for Arc by forwarding the conversion to &T. Since we can’t access T, we work around the naming of associated types by...
Found while attempting to upgrade `pydantic-core` to test out PyO3 `main`. Consider the following code from 0.22. ```rust use pyo3::prelude::*; pub trait Foo(foo: impl Foo where for(foo: impl Foo: pyo3::IntoPyObject`...
The name is confusing now that there is "free-threading" available in Python 3.13. A better name could be `prepare_freestanding_python`.