Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare to release version 0.21.0 #423

Merged
merged 2 commits into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

- Unreleased

- v0.21.0
- Migrate to the new `Bound` API introduced by PyO3 0.21. ([#410](https://github.com/PyO3/rust-numpy/pull/410)) ([#411](https://github.com/PyO3/rust-numpy/pull/411)) ([#412](https://github.com/PyO3/rust-numpy/pull/412)) ([#415](https://github.com/PyO3/rust-numpy/pull/415)) ([#416](https://github.com/PyO3/rust-numpy/pull/416)) ([#418](https://github.com/PyO3/rust-numpy/pull/418)) ([#419](https://github.com/PyO3/rust-numpy/pull/419)) ([#420](https://github.com/PyO3/rust-numpy/pull/420)) ([#421](https://github.com/PyO3/rust-numpy/pull/421)) ([#422](https://github.com/PyO3/rust-numpy/pull/422))
- Add a `prelude` module to simplify importing method traits required by the `Bound` API. ([#417](https://github.com/PyO3/rust-numpy/pull/417))
- Extend documentation to cover some more surprising behaviours. ([#405](https://github.com/PyO3/rust-numpy/pull/405)) ([#414](https://github.com/PyO3/rust-numpy/pull/414))

- v0.20.0
- Increase MSRV to 1.56 released in October 2021 and available in Debain 12, RHEL 9 and Alpine 3.17 following the same change for PyO3. ([#378](https://github.com/PyO3/rust-numpy/pull/378))
- Add support for ASCII (`PyFixedString<N>`) and Unicode (`PyFixedUnicode<N>`) string arrays, i.e. dtypes `SN` and `UN` where `N` is the number of characters. ([#378](https://github.com/PyO3/rust-numpy/pull/378))
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "numpy"
version = "0.20.0"
version = "0.21.0"
authors = [
"The rust-numpy Project Developers",
"PyO3 Project and Contributors <https://github.com/PyO3>"
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ name = "rust_ext"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.20", features = ["extension-module"] }
numpy = "0.20"
pyo3 = { version = "0.21", features = ["extension-module"] }
numpy = "0.21"
```

```rust
Expand Down Expand Up @@ -93,8 +93,8 @@ fn rust_ext<'py>(_py: Python<'py>, m: &Bound<'py, PyModule>) -> PyResult<()> {
name = "numpy-test"

[dependencies]
pyo3 = { version = "0.20", features = ["auto-initialize"] }
numpy = "0.20"
pyo3 = { version = "0.21", features = ["auto-initialize"] }
numpy = "0.21"
```

```rust
Expand Down Expand Up @@ -132,7 +132,7 @@ on anything but that exact range. It can therefore be necessary to manually unif
For example, if you specify the following dependencies

```toml
numpy = "0.20"
numpy = "0.21"
ndarray = "0.13"
```

Expand Down
68 changes: 34 additions & 34 deletions benches/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ use test::{black_box, Bencher};
use std::ops::Range;

use numpy::{PyArray1, PyArray2, PyArray3};
use pyo3::{types::PyAnyMethods, Python, ToPyObject};
use pyo3::{types::PyAnyMethods, Bound, Python, ToPyObject};

#[bench]
fn extract_success(bencher: &mut Bencher) {
Python::with_gil(|py| {
let any = PyArray2::<f64>::zeros_bound(py, (10, 10), false).into_any();

bencher.iter(|| {
black_box(&any).extract::<&PyArray2<f64>>().unwrap();
black_box(&any)
.extract::<Bound<'_, PyArray2<f64>>>()
.unwrap()
});
});
}
Expand All @@ -25,7 +27,9 @@ fn extract_failure(bencher: &mut Bencher) {
let any = PyArray2::<f64>::zeros_bound(py, (10, 10), false).into_any();

bencher.iter(|| {
black_box(&any).extract::<&PyArray2<f64>>().unwrap_err();
black_box(&any)
.extract::<Bound<'_, PyArray2<f64>>>()
.unwrap_err()
});
});
}
Expand All @@ -35,9 +39,7 @@ fn downcast_success(bencher: &mut Bencher) {
Python::with_gil(|py| {
let any = PyArray2::<f64>::zeros_bound(py, (10, 10), false).into_any();

bencher.iter(|| {
black_box(&any).downcast::<PyArray2<f64>>().unwrap();
});
bencher.iter(|| black_box(&any).downcast::<PyArray2<f64>>().unwrap());
});
}

Expand All @@ -46,9 +48,7 @@ fn downcast_failure(bencher: &mut Bencher) {
Python::with_gil(|py| {
let any = PyArray2::<f64>::zeros_bound(py, (10, 10), false).into_any();

bencher.iter(|| {
black_box(&any).downcast::<PyArray2<f64>>().unwrap_err();
});
bencher.iter(|| black_box(&any).downcast::<PyArray2<f64>>().unwrap_err());
});
}

Expand All @@ -63,10 +63,12 @@ impl Iterator for Iter {
}

fn from_iter(bencher: &mut Bencher, size: usize) {
iter_with_gil(bencher, |py| {
let iter = black_box(Iter(0..size));
Python::with_gil(|py| {
bencher.iter(|| {
let iter = black_box(Iter(0..size));

PyArray1::from_iter_bound(py, iter);
PyArray1::from_iter_bound(py, iter)
});
});
}

Expand All @@ -88,10 +90,12 @@ fn from_iter_large(bencher: &mut Bencher) {
fn from_slice(bencher: &mut Bencher, size: usize) {
let vec = (0..size).collect::<Vec<_>>();

iter_with_gil(bencher, |py| {
let slice = black_box(&vec);
Python::with_gil(|py| {
bencher.iter(|| {
let slice = black_box(&vec);

PyArray1::from_slice_bound(py, slice);
PyArray1::from_slice_bound(py, slice)
});
});
}

Expand All @@ -113,10 +117,12 @@ fn from_slice_large(bencher: &mut Bencher) {
fn from_object_slice(bencher: &mut Bencher, size: usize) {
let vec = Python::with_gil(|py| (0..size).map(|val| val.to_object(py)).collect::<Vec<_>>());

iter_with_gil(bencher, |py| {
let slice = black_box(&vec);
Python::with_gil(|py| {
bencher.iter(|| {
let slice = black_box(&vec);

PyArray1::from_slice_bound(py, slice);
PyArray1::from_slice_bound(py, slice)
});
});
}

Expand All @@ -138,10 +144,12 @@ fn from_object_slice_large(bencher: &mut Bencher) {
fn from_vec2(bencher: &mut Bencher, size: usize) {
let vec2 = vec![vec![0; size]; size];

iter_with_gil(bencher, |py| {
let vec2 = black_box(&vec2);
Python::with_gil(|py| {
bencher.iter(|| {
let vec2 = black_box(&vec2);

PyArray2::from_vec2_bound(py, vec2).unwrap();
PyArray2::from_vec2_bound(py, vec2).unwrap()
});
});
}

Expand All @@ -163,10 +171,12 @@ fn from_vec2_large(bencher: &mut Bencher) {
fn from_vec3(bencher: &mut Bencher, size: usize) {
let vec3 = vec![vec![vec![0; size]; size]; size];

iter_with_gil(bencher, |py| {
let vec3 = black_box(&vec3);
Python::with_gil(|py| {
bencher.iter(|| {
let vec3 = black_box(&vec3);

PyArray3::from_vec3_bound(py, vec3).unwrap();
PyArray3::from_vec3_bound(py, vec3).unwrap()
});
});
}

Expand All @@ -184,13 +194,3 @@ fn from_vec3_medium(bencher: &mut Bencher) {
fn from_vec3_large(bencher: &mut Bencher) {
from_vec3(bencher, 2_usize.pow(5));
}

fn iter_with_gil(bencher: &mut Bencher, mut f: impl FnMut(Python<'_>)) {
Python::with_gil(|py| {
bencher.iter(|| {
let pool = unsafe { py.new_pool() };

f(pool.python());
});
});
}
2 changes: 1 addition & 1 deletion src/sum_products.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ where
obj.extract()
}

/// Deprecated form of [`einsum_bound!`]
/// Deprecated form of [`einsum_bound!`][crate::einsum_bound!]
#[deprecated(
since = "0.21.0",
note = "will be replaced by `einsum_bound!` in the future"
Expand Down
Loading