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

New Bound API implementation tracking issue #3684

Closed
63 tasks done
davidhewitt opened this issue Dec 21, 2023 · 29 comments
Closed
63 tasks done

New Bound API implementation tracking issue #3684

davidhewitt opened this issue Dec 21, 2023 · 29 comments

Comments

@davidhewitt
Copy link
Member

davidhewitt commented Dec 21, 2023

This is a tracking issue for #3382


PRs currently waiting for review (all input is greatly appreciated, doesn't need to be an existing maintainer):

#3708


TODO (this list is a fairly good coverage of all PRs which occurred for the Bound implementation, but it is probably not complete):


Possible polish to consider later: Moved to #3960


I'll try to keep this updated as we go, and probably there are items which I've missed right now.

If anyone wants to claim any of these unassigned tasks, please ping here and I'll update this so that we don't race.

@davidhewitt
Copy link
Member Author

What to do with constructors e.g. PyTuple::new which return gil refs?
Add deprecation or other nudge to encourage users to migrate to new API without blocking their compiles.

I'm wondering if we can kill two birds with one stone here:

  • change constructors to return bound, e.g. PyTuple::new() -> Bound<'_, PyTuple>, to require users to at least handle this
  • deprecate APIs which convert to gil refs: Bound::into_gil_ref, Py::as_ref, Py::into_ref

That should produce a relatively small number of deprecation warnings and compile failures, while making it relatively easy for users to keep going with these APIs for now if they wish.

Then in 0.22 we can get more aggressive about gating the whole lot of gil ref APIs away with a feature etc.

@davidhewitt
Copy link
Member Author

Generally I've put myself down for anything that involves wrangling with the #3606 branch, as I'm quite familiar with what's on there and have been rebasing it fairly regularly to keep up with adjustments that we decide in review. I'll proceed to rebase + split that branch up into PRs so that we can get all that in.

One exception: I'm going to start immediately with a PR to do the renaming of Py2 -> Bound, because that's going to conflict with literally everything else.

@adamreichold
Copy link
Member

Replacing internal gil-ref uses with new API (not a blocker for release but highly desirable)

I know it is a lot of additional work, but we might want to treat this as a blocker, so that we are at least compatible with gevent by never touching the pool if the user code does not do it explicitly.

Add deprecation or other nudge to encourage users to migrate to new API without blocking their compiles.

I also think we should definitely put the pool behind a feature, at the minimum to enable internal testing whether so a no-pool build is complete and works which I think would not be possible via deprecation. I am still undecided whether to argue for default-on or default-off though.

@davidhewitt
Copy link
Member Author

I know it is a lot of additional work, but we might want to treat this as a blocker, so that we are at least compatible with gevent by never touching the pool if the user code does not do it explicitly.

Sure thing. TBH I think a very large chunk of that is on #3606 because I worked hard to get pydantic-core off the pool in all benchmarks. It might be that if we add the deprecation to as_ref and into_ref we will flush out a lot of the remaining pieces of this too.

I also think we should definitely put the pool behind a feature, at the minimum to enable internal testing whether so a no-pool build is complete and works which I think would not be possible via deprecation. I am still undecided whether to argue for default-on or default-off though.

I'd slightly prefer default-off, because we only get one time really to ask users to add default-features = false before they probably leave this in their Cargo.toml and forget about it. I also am relatively tempted to not test this feature on our CI (maybe except for lint), to avoid a huge duplication of tests, and it's easier to get away with that if we label this feature as optional and unsafe / unsupported.

@davidhewitt
Copy link
Member Author

Added item about updating py.None() etc.

@davidhewitt
Copy link
Member Author

I've added a section which lists the reviews currently outstanding, to help direct attention towards the PRs which will move this forward.

@davidhewitt
Copy link
Member Author

davidhewitt commented Feb 1, 2024

If reviewers are trying to decide what to look review next, #3776 would be extremely helpful as I think that's the final piece of design decision which would then allow me to finish splitting #3606 into sub-PRs.

snuderl added a commit to snuderl/pyo3 that referenced this issue Feb 3, 2024
snuderl added a commit to snuderl/pyo3 that referenced this issue Feb 3, 2024
@davidhewitt
Copy link
Member Author

@Icxolu @snuderl as there's now three of us implementing pieces off this list, perhaps let's message here before we start implementing things just so that we don't end up duplicating work?

For my side, I have a few PRs still open for review which are listed above. Next time I have a good moment for implementation, I think my attention is best spent finishing #3744. I'd also like to write the update for types.md ASAP.

@davidhewitt
Copy link
Member Author

I also added a bunch of items which I know are still missing under the "Add Bound constructor variants to all Python types" bullet above.

github-merge-queue bot pushed a commit that referenced this issue Feb 4, 2024
@Icxolu
Copy link
Contributor

Icxolu commented Feb 4, 2024

Good idea, pyo3::marshal I have ready, I'll open that PR in a moment. Next I think I'll look at porting marker::Python

@LilyFoote
Copy link
Contributor

Sounds to me like Discord is easiest.

@davidhewitt
Copy link
Member Author

👍 https://discord.gg/c4BwayXQ

@davidhewitt
Copy link
Member Author

@LilyFoote @Icxolu, as you two have been helping so much with this implementation (thank you so much, you have really sped things up), I thought I'd just take stock quickly and see what we think there is left remaining before release.

There are a few bullets left unchecked, mostly around internal cleanup and documentation now.

Do you see much else remaining? Do you have items you plan to do, or want to take on from the above list? I'm hopeful we can finally release this within the next two weeks! 🚀

@Icxolu
Copy link
Contributor

Icxolu commented Feb 24, 2024

I think this sums it up quite nicely. &Bound in #[pymodule] and wrap_pyfunction_bound would probably be nice having for updating examples and documentation, so that we can remove all into/as_gil_ref() and as_borrowed in there.

I've just looked into allowing Bound in #[pymethod] self position, further discouraging use of &PyCell there. Seems like the tests finally pass, so I can push that shortly.

@davidhewitt
Copy link
Member Author

Ok, I got around to updating my PRs.

#3860 should be good to review again.

#3708 is also good to review, but we should find the performance regression is not present after #3860 is merged, if we want to wait for that to go in first.

@davidhewitt
Copy link
Member Author

Off the back of #3897 (comment) - I think we did previously intend to seal the Methods traits, just never got around to it. That would be a good thing to do before we release, I think, as we will struggle to seal them once they are user-accessible.

@davidhewitt
Copy link
Member Author

I just thought of #3928 which might solve the &str question.

@davidhewitt
Copy link
Member Author

This is so close to ready now, thank you so much everyone!

I just added a bunch of new bullets with ideas of further places the proc macro code could emit deprecation warnings. I hope to start taking a look at those after we've pushed a beta release. If anyone else feels like having a play with them, feel free to do so.

Other than that, I'm going to hopefully see #3928 and #3906 done and then get the beta release live.

Hopefully we can get the deprecation warnings solved relatively quickly and then prep the final 0.21 release!

@davidhewitt
Copy link
Member Author

I think with the last couple PRs, this list is now, finally complete. What a huge effort here, thank you everyone!

I've moved the follow-ups to #3960 and I think it makes sense to continue there, this issue is long enough already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants