-
Notifications
You must be signed in to change notification settings - Fork 731
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
RFC: Make pyclass immutable by default #4369
Comments
What's the pathway to getting where we'd like to be? I was actually thinking I'm quite happy with I think we also haven't yet worked out the exact semantics of the pyclass borrow tracking under the freethreaded Python builds. It might inform some further changes we want to make in this area. |
I would also add that frozen is not very self-describing about what it does. (At least it wasn't for me, maybe a python thing to call const thing frozen ?) |
Yes, e.g. |
Hey I think this will be useful as well to "unblock" (it is not actually blocked but the user will need to have knowledge of such nuances) the usage of the vector call protocol for >=3.12.
For this reason the "Py_TPFLAGS_IMMUTABLE" was proposed. Indeed, you can see in the original issue (88074) that several libraries that were using the vector protocol have been made immutable. |
I can take this issue |
@gabriel4k2 this is for immutable class instances, not immutable types, but both are closely related I guess. For immutable types, I think I'm coming around to the idea that the correct default is to leave classes mutable. It is not uncommon for there to be monkey patching etc and although I don't love it, it is a pattern in Python which has use cases (especially in testing). I'll comment more on #2349. For instances, I think we need to make a decision what we want the semantics of mutable objects with the free threading build. I will try to think and make a proposal in the coming weeks. |
In #1979 (review) we discussed that we'd like to have
#[pyclass(mutable)]
, making pyclasses immutable by default and mutability opt-in.Currently we have
#[pyclass(frozen)]
where this is the other way around; they are mutable by default.The text was updated successfully, but these errors were encountered: