PyO3 / rust-numpy

PyO3-based Rust bindings of the NumPy C-API
BSD 2-Clause "Simplified" License
1.07k stars 98 forks source link

disable pyo3's `gil-refs` migration feature #420

Closed Icxolu closed 3 months ago

Icxolu commented 4 months ago

This disables pyo3s gil-ref migration feature, and fixes all the deprecations that are still left.

One major change to note is in PyArrayDescr::names, which I changed to return a Vec<PyBackedStr> instead of Vec<&str>. I don't think we can support the old signature anymore without gil-refs.

I noticed here that PyBacked* does not implement Debug. Maybe we should add one in pyo3 (which could just delegate to the debug of the Deref::Target). Some PartialEq / Eq impls could also be nice I think. cc @davidhewitt

davidhewitt commented 4 months ago

I noticed here that PyBacked* does not implement Debug. Maybe we should add one in pyo3 (which could just delegate to the debug of the Deref::Target). Some PartialEq / Eq impls could also be nice I think. cc @davidhewitt

Definitely. I think we could even have PartialEq<&str> or similar. Maybe we should also have implemented Hash, Ord, and PartialOrd?

I also just separately had noticed Send/Sync were missing https://github.com/PyO3/pyo3/pull/4007

These types were definitely a somewhat-last-minute addition that have turned out to be super useful (in particular PyBackedStr) and need some additional love and documentation!

adamreichold commented 3 months ago

One more thing I just noticed is that we now have access to Borrowed::to_owned which should allow us to get rid of a FIXME somewhere IIRC.

adamreichold commented 3 months ago

@Icxolu So if I am not mistaken this is it to make rust-numpy useful as dependency together with pyo3 0.21? Meaning I will cut a 0.21 release now or is there anything you still want to do before that?

(Regarding my own PR, I don't think the ufunc support is pressing enough to delay the release with the whole PyO3 ecosystem using to the new bound API.)

Icxolu commented 3 months ago

I think at this point rust-numpy should be compatible and useful together with pyo3 0.21. The things (I'm aware of) that are left are

Both of these should be only additive (introducting _bound variant, and deprecating the old one), so I think it would also be fine to leave them for a point release. I'll leave that up to you.

In any case a big thanks for all the reviewing ❤️