Skip to content

Commit 831a855

Browse files
Merge branch 'main' into descriptor
2 parents c36a08d + f89e4ad commit 831a855

111 files changed

Lines changed: 1385 additions & 611 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/benches.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ jobs:
2020
- uses: actions/checkout@v6.0.2
2121
- uses: astral-sh/setup-uv@v7
2222
with:
23-
# codspeed action needs to be run from within the final Python environment
24-
activate-environment: true
2523
save-cache: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }}
24+
25+
# Using this action is still necessary for CodSpeed to build flamegraphs correctly,
26+
# see note about setup-python in https://codspeed.io/docs/benchmarks/python#recipes
27+
- uses: actions/setup-python@v6
28+
with:
29+
python-version: ${{ env.UV_PYTHON }}
30+
2631
- uses: dtolnay/rust-toolchain@stable
2732
with:
2833
components: rust-src

.github/workflows/netlify-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
5252
- name: Post Netlify Preview Status to PR
5353
if: ${{ github.event.workflow_run.event == 'pull_request' }}
54-
uses: actions/github-script@v8
54+
uses: actions/github-script@v9
5555
with:
5656
github-token: ${{ secrets.GITHUB_TOKEN }}
5757
script: |

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ chrono = { version = "0.4.25", default-features = false, optional = true }
4545
chrono-tz = { version = ">= 0.10, < 0.11", default-features = false, optional = true }
4646
either = { version = "1.9", optional = true }
4747
eyre = { version = ">= 0.6.8, < 0.7", optional = true }
48-
hashbrown = { version = ">= 0.15.0, < 0.17", optional = true, default-features = false }
48+
hashbrown = { version = ">= 0.15.0, < 0.18", optional = true, default-features = false }
4949
indexmap = { version = ">= 2.5.0, < 3", optional = true }
5050
jiff-02 = { package = "jiff", version = "0.2", optional = true }
5151
num-bigint = { version = "0.4.4", optional = true }

guide/src/function/signature.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,9 @@ Type: builtin_function_or_method
265265

266266
### Type annotations in the signature
267267

268-
When the `experimental-inspect` Cargo feature is enabled, the `signature` attribute can also contain type hints:
268+
The `signature` attribute can also contain type hints:
269269

270270
```rust
271-
# #[cfg(feature = "experimental-inspect")] {
272271
use pyo3::prelude::*;
273272

274273
#[pymodule]
@@ -281,21 +280,21 @@ pub mod example {
281280
arg
282281
}
283282
}
284-
# }
285283
```
286284

287285
It enables the [work-in-progress capacity of PyO3 to autogenerate type stubs](../type-stub.md) to generate a file with the correct type hints:
288286

289287
```python
290-
def list_of_int_identity(arg: list[int]) -> list[int]: ...
288+
def list_of_int_identity(arg: "list[int]") -> "list[int]": ...
291289
```
292290

293291
instead of the generic:
294292

295293
```python
296-
import typing
294+
from typing import Any
297295

298-
def list_of_int_identity(arg: typing.Any) -> typing.Any: ...
296+
def list_of_int_identity(arg: Any) -> Any: ...
299297
```
300298

301-
Note that currently type annotations must be written as Rust strings.
299+
Note that currently type annotations must be written as strings.
300+
Future enhancements of PyO3's typing support may include the ability to parse a limited subset of Python's type expression syntax.

guide/src/type-stub.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ class Class:
6666
def __eq__(self, other: Class) -> bool: ...
6767
def __ne__(self, other: Class) -> bool: ...
6868

69-
def list_of_int_identity(arg: list[int]) -> list[int]: ...
69+
def list_of_int_identity(arg: "list[int]") -> "list[int]": ...
7070
```
7171

72-
The only piece of added syntax is that the `#[pyo3(signature = ...)]` attribute can now contain type annotations like `#[pyo3(signature = (arg: "list[int]") -> "list[int]")]` (note the `""` around type annotations).
72+
The only piece of new syntax is that the `#[pyo3(signature = ...)]` attribute can contain type annotations like `#[pyo3(signature = (arg: "list[int]") -> "list[int]")]` (note the `""` around type annotations).
7373
This is useful when PyO3 is not able to derive proper type annotations by itself.
7474

7575
## Constraints and limitations

newsfragments/5942.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add FFI definitions `PyObject_GetAIter`, `PyAIter_Check`, `PyMapping_HasKeyWithError`, `PyMapping_HasKeyStringWithError`, `PyMapping_GetOptionalItem`, `PyMapping_GetOptionalItemString`, `PySequence_ITEM`, `PySequence_Fast_GET_SIZE`, `PySequence_Fast_GET_ITEM`, and `PySequence_Fast_ITEMS`.

newsfragments/5942.removed.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Remove private FFI definitions `_PyStack_AsDict`, `_PyObject_CallNoArg`, `_PyObject_FastCall`, `_PyObject_FastCallTstate`. `_PyObject_VectorcallTstate`, `_PyObject_MakeTpCall`, `_Py_CheckFunctionResult`, `_PyObject_CallFunction_SizeT`, `_PyObject_CallMethod_SizeT`, and `_PySequence_IterSearch`.
2+
3+
Remove FFI definitions `PY_ITERSEARCH_COUNT`, `PY_ITERSEARCH_INDEX`, and `PY_ITERSEARCH_CONTAINS`.

newsfragments/5946.changed.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Removed use of the CPython-internal `_PyUnicode_COMPACT_DATA` symbol from PyO3's FFI test suite.
2+
Removed `_PySet_NextEntry` in `pyo3-ffi`; it is a CPython-internal API with no stability guarantee.
3+
Removed `_PyLong_NumBits` in `pyo3-ffi` and replaced its internal use with `int.bit_length()` for Python < 3.13 builds.

newsfragments/5947.added.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Added the following functions:
2+
3+
* pub fn PyDict_SetDefault(mp: *mut PyObject, key: *mut PyObject, default_obj: *mut PyObject) -> *mut PyObject;
4+
* pub fn PyDict_SetDefaultRef(mp: *mut PyObject, key: *mut PyObject, default_obj: *mut PyObject, result: **mut PyObject) -> c_int;
5+
* pub fn PyDict_ContainsString(mp: *mut PyObject, key: *const char) -> c_int;
6+
* pub fn PyDict_Pop(dict: *mut PyObject, key: *mut PyObject, result: **mut PyObject) -> c_int;
7+
* pub fn PyDict_PopString(dict: *mut PyObject, key: *const c_char, result: **mut PyObject) -> c_int;
8+
* pub fn PyDict_ClearWatcher(watcher_id: c_int) -> c_int;
9+
* pub fn PyDict_Watch(watcher_id: c_int, dict: *mut PyObject) -> c_int;
10+
* pub fn PyDict_Unwatch(watcher_id: c_int, dict: *mut PyObject) -> c_int;
11+
* pub fn PyFrozenDict_New(iterable: *mut PyObject) -> *mut PyObject;

newsfragments/5949.added.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Added the following functions:
2+
3+
* PyDate_FromDate
4+
* PyDateTime_FromDateAndTime
5+
* PyDateTime_FromDateAndTimeAndFold
6+
* PyTime_FromTime
7+
* PyTime_FromTimeAndFold
8+
* PyDelta_FromDSU

0 commit comments

Comments
 (0)