Skip to content

Commit 2587fd9

Browse files
authored
Merge pull request #280 from PyO3/deprecate-npyiter
Deprecate the wrappers of the array iterator API.
2 parents 126a9e7 + b3be43a commit 2587fd9

File tree

6 files changed

+212
-115
lines changed

6 files changed

+212
-115
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Fixed downcasting ignoring element type and dimensionality ([#265](https://github.com/PyO3/rust-numpy/pull/265))
88
- `PyArray::new` is now `unsafe`, as it produces uninitialized arrays ([#220](https://github.com/PyO3/rust-numpy/pull/220))
99
- `PyArray::iter`, `NpySingleIterBuilder::readwrite` and `NpyMultiIterBuilder::add_readwrite` are now `unsafe`, as they allow aliasing mutable references to be created ([#278/](https://github.com/PyO3/rust-numpy/pull/278))
10+
- The `npyiter` module is deprecated as rust-ndarray's facilities for iteration are more flexible and performant ([#280](https://github.com/PyO3/rust-numpy/pull/280))
1011
- `PyArray::from_exact_iter` does not unsoundly trust `ExactSizeIterator::len` any more ([#262](https://github.com/PyO3/rust-numpy/pull/262))
1112
- `PyArray::as_cell_slice` was removed as it unsoundly interacts with `PyReadonlyArray` allowing safe code to violate aliasing rules ([#260](https://github.com/PyO3/rust-numpy/pull/260))
1213
- `rayon` feature is now removed, and directly specifying the feature via `ndarray` dependency is recommended ([#250](https://github.com/PyO3/rust-numpy/pull/250))

src/array.rs

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use crate::convert::{ArrayExt, IntoPyArray, NpyIndex, ToNpyDims, ToPyArray};
2323
use crate::dtype::{Element, PyArrayDescr};
2424
use crate::error::{DimensionalityError, FromVecError, NotContiguousError, TypeError};
2525
use crate::npyffi::{self, npy_intp, NPY_ORDER, PY_ARRAY_API};
26+
#[allow(deprecated)]
2627
use crate::npyiter::{NpySingleIter, NpySingleIterBuilder, ReadWrite};
2728
use crate::readonly::PyReadonlyArray;
2829
use crate::slice_container::PySliceContainer;
@@ -1079,6 +1080,10 @@ impl<T: Element> PyArray<T, Ix1> {
10791080
///
10801081
/// The iterator will produce mutable references into the array which must not be
10811082
/// aliased by other references for the life time of the iterator.
1083+
#[deprecated(
1084+
note = "The wrappers of the array iterator API are deprecated, please use ndarray's `ArrayBase::iter_mut` instead."
1085+
)]
1086+
#[allow(deprecated)]
10821087
pub unsafe fn iter<'py>(&'py self) -> PyResult<NpySingleIter<'py, T, ReadWrite>> {
10831088
NpySingleIterBuilder::readwrite(self).build()
10841089
}

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ pub use crate::convert::{IntoPyArray, NpyIndex, ToNpyDims, ToPyArray};
5656
pub use crate::dtype::{dtype, Complex32, Complex64, Element, PyArrayDescr};
5757
pub use crate::error::{DimensionalityError, FromVecError, NotContiguousError, TypeError};
5858
pub use crate::npyffi::{PY_ARRAY_API, PY_UFUNC_API};
59+
#[allow(deprecated)]
5960
pub use crate::npyiter::{
6061
IterMode, NpyIterFlag, NpyMultiIter, NpyMultiIterBuilder, NpySingleIter, NpySingleIterBuilder,
6162
};

0 commit comments

Comments
 (0)