-
Notifications
You must be signed in to change notification settings - Fork 784
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
implement PyTupleMethods
#3681
implement PyTupleMethods
#3681
Conversation
CodSpeed Performance ReportMerging #3681 will improve performances by 24.39%Comparing Summary
Benchmarks breakdown
|
fd637f8
to
6719e98
Compare
@adamreichold I've rebased this PR on all the changes we've merged recently. I also pushed two additional commits to make this PR go further than the other
The interesting idea I had is that with the There's two nice upsides to this:
|
6719e98
to
e29e2ae
Compare
I have not yet looked at the code in question, but from the description I have to admit that I am not enthusiastic:
To me, it feels like we are continuously oscillating between "this will already be a hefty migration, let's avoid any unnecessary breakage" and "that pool-free future is glorious and I want to take everybody there with us, now". Personally, I am strongly in the first camp, I'd like us to use the next release to introduce the new API and their significant benefits to downstream projects but leave it as a completely optional thing that projects can look into at their own pace. Even deprecating the non-pool API is a pretty strong approach IMHO, but at least that can be easily silenced using |
Hmm, yes I take your point. I think the thing that pains me is that it feels like we will be publishing 0.21 (and probably 0.22) with an API story that is very much "this is in migration, and we'll be asking you to join us in finishing off migration in a future release". And maybe that's just the inevitable reality of it. I agree that this particular proposal of a I'll drop that last commit and let's continue to focus on getting the API feature complete first. |
a747b7a
to
77c5063
Compare
8d611c8
to
57b5232
Compare
Looking at how these deprecations are affecting even just our own code, I'm beginning to think maybe we should go even slower and not even deprecate stuff? #3703 (comment) As keen as I am to get everyone onto a safer and more performant API, I think patience and good documentation of how and why the changes are occurring might be a better route than trying to encourage a rapid migration. |
Yes, I think shipped without any deprecations of the GIL ref API would be a better experience for our downstream projects. The main reason, I would like to add them is that this is usually part of our removal story, i.e. deprecate in version N and remove in version N+2. So if do not do this, we need to wait until N+3 for removal? Our maybe we use something like the pinned issue to tell people that we did not deprecate but still plan to remove in N+2 after deprecating in N+1? (If we add a |
Going off the In 0.22 we go further and gate the APIs behind the And then in 0.23 (or maybe 0.24 if we feel conservative at the time) we remove the APIs and the feature entirely? I think that should both create an additive feature and also hopefully a realistic vision for how we can ship 0.21? |
6897f66
to
8e699bf
Compare
8e699bf
to
52697fa
Compare
6a8a207
to
e0e4197
Compare
e0e4197
to
4cf58c8
Compare
Split off from #3606
There are a few interesting pieces going on here, because it is safe to borrow items from a
tuple
due to its immutability:.into_iter()
on aPy2<PyTuple>
because the reference is then owned by the iterator, and we don't have lending iterators in Rust yet.PyTupleIterator2
as yielding owned objects..iter_borrowed()
method, which creates an iteratorPyTupleIterBorrowed
which yieldsPy2Borrowed
items. The gil-ref iterator wraps this borrowing iterator.get_item
borrows objects. To keep types predictable on the migration from&PyAny
->Py2<'py, PyAny>
the newget_item
returns owned objects, and I have addedget_borrowed_item
which returns borrowed objects and is what the gil-ref API wraps.This way the more efficient "borrowed" methods are still available, but users have to opt-into them. I'd argue this creates a simpler migration pathway while also leaving the more efficient operations available for us to use.
Finally, it turns out that to implement this it starts getting useful if
Py2Borrowed
implementsCopy
(which seems reasonable as it's basically a pointer), so I've pushed that as a precursor commit.