-
Notifications
You must be signed in to change notification settings - Fork 921
add gil-refs-migration feature
#3962
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
Conversation
f682f36 to
402b5f5
Compare
402b5f5 to
8d9a39d
Compare
Icxolu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! After #3959, this would only affect trait qualified syntax (FromPyObject::extract) which extract one of the borrowed types, right? I'm don't know how common that is, and if it warrants a separate feature, but I'm completely fine having it.
One disadvantage I could see is that something like this
let obj: Bound<'py, PyType> = py.get_type_bound::<PyList>();
let name: &'py str = obj.getattr("__name__")?.extract()?;will still compile with gil-refs-migration enabled and then start failing once disabled. I guess that's the trade-off if we want to keep compile errors minimal while still enabling deprecation warnings.
I think it's a little more than just the syntax, it's about delaying the breakages caused by the lifetime change for the
Yes, though I was hoping it's an advantage of this feature to allow the rest of the code to migrate first, rather than a disadvantage :) |
But these breakages do only occur once users actively migrating the code, right? Just turning off |
Right I see, because now that #3959 is merged, not only does it allow So the only break which this feature would now help avoid is users working with So maybe this feature is indeed an overcomplication. I had few other possible things I was wondering for this feature:
I would say while those ideas might help users, they are not necessarily obvious or intuitive, so perhaps for the sake of simplicity we should back out from this. |
No worries 😄, I could have also just overlooked something as well.
I while back I also though about if we should deprecate the inherent methods. Deprecating only the ones that return gil-refs feels a bit arbitrary to me, because they all operate on gil-refs and fundamentally are all deprecated. But actually marking all of them as deprecated will cause a lot of warning without immediate action, since resolving them requires the migration of the receiver and not the method itself. We have deprecated all the constructors and most of the macros (I think Another option could maybe be to deprecate them under a rustc
Is there a case that we reasonably could expect that to break anything? It looks like every method that I think makes sense to use it in conjunction with ( |
|
Yes, I agree with all of the above. I think the case for this feature is not strong enough. A |
Closes #3958
This PR implements the
gil-refs-migrationfeature as proposed in that issue, and moves theFromPyObjectBoundimplementations to be gated on that feature.This way users can migrate the rest of the Bound API deprecations without immediately being broken by the extract changes.
I also added open-by-default details tags to the 0.21 migration guide as per #3961.