PyO3 v0.16.0 Release Notes
Release Date: 2022-02-27 // about 2 years ago-
Packaging
- ⚡️ Update MSRV to Rust 1.48. #2004
- ⚡️ Update
indoc
optional dependency to 1.0. #2004 - ⬇️ Drop support for Python 3.6, remove
abi3-py36
feature. #2006 - 🏗
pyo3-build-config
no longer enables theresolve-config
feature by default. #2008 - ⚡️ Update
inventory
optional dependency to 0.2. #2019 - ⬇️ Drop
paste
dependency. #2081 - The bindings found in
pyo3::ffi
are now a re-export of a separatepyo3-ffi
crate. #2126 - 👌 Support PyPy 3.9. #2143
➕ Added
- ➕ Add
PyCapsule
type exposing the Capsule API. #1980 - 🏗 Add
pyo3_build_config::Sysconfigdata
and supporting APIs. #1996 - ➕ Add
Py::setattr
method. #2009 - ➕ Add
#[pyo3(crate = "some::path")]
option to all attribute macros (except the deprecated#[pyproto]
). #2022 - 📄 Enable
create_exception!
macro to take an optional docstring. #2027 - Enable
#[pyclass]
for fieldless (aka C-like) enums. #2034 - Add buffer magic methods
__getbuffer__
and__releasebuffer__
to#[pymethods]
. #2067 - Add support for paths in
wrap_pyfunction
andwrap_pymodule
. #2081 - Enable
wrap_pyfunction!
to wrap a#[pyfunction]
implemented in a different Rust module or crate. #2091 - ➕ Add
PyAny::contains
method (in
operator forPyAny
). #2115 - ➕ Add
PyMapping::contains
method (in
operator forPyMapping
). #2133 - Add garbage collection magic magic methods
__traverse__
and__clear__
to#[pymethods]
. #2159 - Add support for
from_py_with
on struct tuples and enums to override the default from-Python conversion. #2181 - ➕ Add
eq
,ne
,lt
,le
,gt
,ge
methods toPyAny
that wraprich_compare
. #2175 - ➕ Add
Py::is
andPyAny::is
methods to check for object identity. #2183 - Add support for the
__getattribute__
magic method. #2187
🔄 Changed
PyType::is_subclass
,PyErr::is_instance
andPyAny::is_instance
now operate run-time type object instead of a type known at compile-time. The old behavior is still available asPyType::is_subclass_of
,PyErr::is_instance_of
andPyAny::is_instance_of
. #1985- 🗄 Rename some methods on
PyErr
(the old names are just marked deprecated for now): #2026pytype
->get_type
pvalue
->value
(and deprecate equivalentinstance
)ptraceback
->traceback
from_instance
->from_value
into_instance
->into_value
- 📄
PyErr::new_type
now takes an optional docstring and now returnsPyResult<Py<PyType>>
rather than affi::PyTypeObject
pointer. #2027 - Deprecate
PyType::is_instance
; it is inconsistent with otheris_instance
methods in PyO3. Instead oftyp.is_instance(obj)
, useobj.is_instance(typ)
. #2031 __getitem__
,__setitem__
and__delitem__
in#[pymethods]
now implement both a Python mapping and sequence by default. #2065- 👌 Improve performance and error messages for
#[derive(FromPyObject)]
for enums. #2068 - ⬇️ Reduce generated LLVM code size (to improve compile times) for:
- Respect Rust privacy rules for items wrapped with
wrap_pyfunction
andwrap_pymodule
. #2081 - Add modulo argument to
__ipow__
magic method. #2083 - 🛠 Fix FFI definition for
_PyCFunctionFast
. #2126 PyDateTimeAPI
andPyDateTime_TimeZone_UTC
are are now unsafe functions instead of statics. #2126PyDateTimeAPI
does not implicitly callPyDateTime_IMPORT
anymore to reflect the original Python API more closely. Before the first call toPyDateTime_IMPORT
a null pointer is returned. Therefore before calling any of the following FFI functionsPyDateTime_IMPORT
must be called to avoid undefined behaviour: #2126PyDateTime_TimeZone_UTC
PyDate_Check
PyDate_CheckExact
PyDateTime_Check
PyDateTime_CheckExact
PyTime_Check
PyTime_CheckExact
PyDelta_Check
PyDelta_CheckExact
PyTZInfo_Check
PyTZInfo_CheckExact
PyDateTime_FromTimestamp
PyDate_FromTimestamp
- Deprecate the
gc
option forpyclass
(e.g.#[pyclass(gc)]
). Just implement a__traverse__
#[pymethod]
. #2159 - The
ml_meth
field ofPyMethodDef
is now represented by thePyMethodDefPointer
union. 2166 - 🗄 Deprecate the
#[pyproto]
traits. #2173
✂ Removed
- ✂ Remove all functionality deprecated in PyO3 0.14. #2007
- ✂ Remove
Default
impl forPyMethodDef
. #2166 - ✂ Remove
PartialEq
impl forPy
andPyAny
(use the newis()
instead). #2183
🛠 Fixed
- 🛠 Fix undefined symbol for
PyObject_HasAttr
on PyPy. #2025 - 🛠 Fix memory leak in
PyErr::into_value
. #2026 - 🛠 Fix clippy warning
needless-option-as-deref
in code generated by#[pyfunction]
and#[pymethods]
. #2040 - 🛠 Fix undefined behavior in
PySlice::indices
. #2061 - 🛠 Fix the
wrap_pymodule!
macro using the wrong name for a#[pymodule]
with a#[pyo3(name = "..")]
attribute. #2081 - 🛠 Fix magic methods in
#[pymethods]
accepting implementations with the wrong number of arguments. #2083 - 🛠 Fix panic in
#[pyfunction]
generated code when a required argument following anOption
was not provided. #2093 - 🛠 Fixed undefined behaviour caused by incorrect
ExactSizeIterator
implementations. #2124 - 🛠 Fix missing FFI definition
PyCMethod_New
on Python 3.9 and up. #2143 - Add missing FFI definitions
_PyLong_NumBits
and_PyLong_AsByteArray
on PyPy. #2146 - 🛠 Fix memory leak in implementation of
AsPyPointer
forOption<T>
. #2160 - Fix FFI definition of
_PyLong_NumBits
to returnsize_t
instead ofc_int
. #2161 - 🛠 Fix
TypeError
thrown when argument parsing failed missing the originating causes. 2177