You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I propose to add a type to support copy-on-write behavior just like the std::borrow::Cow. The Cow type in std is usually unwanted because a reference to a Python object is held though PyRef. Therefore something like the following will be useful:
This is useful when a function accepts both a Python object or something that can be converted to the object. For example, if I have a rust-implemented Python-type Decimal, a function that accepts a either Decimal or a string can take this as input to prevent a copy.
(Not sure if this is useful for other people, or if it's compatible with the new Bound API or not... Just post the idea here for discussion)
The text was updated successfully, but these errors were encountered:
I think there is definitely space for this kind of idea, and it is strongly related to what we just added in #3802 . There's a lot of unresolved questions in my head about this, though.
is it limited to B: PyClass or B: PyTypeInfo?
does it store PyRef or Bound for the python variant?
does it try to add a third &B variant to become a complete superset of normal Cow?
Folks willing to explore this idea further are very welcome, whether it gets merged immediately into pyo3 or we allow time for this idea to mature as a separate crate, I can see potential in it.
I propose to add a type to support copy-on-write behavior just like the
std::borrow::Cow
. TheCow
type instd
is usually unwanted because a reference to a Python object is held thoughPyRef
. Therefore something like the following will be useful:This is useful when a function accepts both a Python object or something that can be converted to the object. For example, if I have a rust-implemented Python-type
Decimal
, a function that accepts a eitherDecimal
or a string can take this as input to prevent a copy.(Not sure if this is useful for other people, or if it's compatible with the new
Bound
API or not... Just post the idea here for discussion)The text was updated successfully, but these errors were encountered: