-
Notifications
You must be signed in to change notification settings - Fork 760
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
Get rid of specialization: Roadmap #697
Comments
I've been thinking hard about the conversion table you drew out. I think this problem is closely related to #679. Using the suggested design from #679, I would like to propose the table should look like this:
Going from the stack to the python heap could be done with It should also be possible to borrow from either of the first two rows to obtain the third. It should never be possible to go from a borrow to either of the first two forms. |
I refer to
this should be discussed in #679. |
Apparently this is a follow-up issue of #210 and here goes a small TODO list for getting rid of specialization.
Yeah, but... please understand opening this means we are ready to resolve this soon!
I'll be busy for a while.
ObjectProtocol
This is the main use of specialization.
To resolve this we can use @konstin 's inventory trick(Poc dunder without specialization #552) or my dirty trick with provider trait.
Conversion
Like this.
It is good that New #[pyclass] system that is aware of its concrete layout #683 makes pyclass detection easier and I think we can resolve this with not so complex implementation.
But what can be problematic is some conversion traits depend on
ToPyObject
trait, which I really don't like.Now we can distinguish Rust-native and Python-native objects if we have
T: TypeInfo
, but, forToPyObject
, we cannot do it.Just adding
PyTypeInfo
bound might work, but I really don't like this situation.In my new semantics proposed in New #[pyclass] system that is aware of its concrete layout #683, our conversion hierarchy is like this:
T: PyClass
PyClassShell<T>
<T as PyTypeInfo>::ConcreteLayout
&T
or&PyClassShell<T>
&T
So, yeah, we can convert
T: PyClass
to Python objects..., but we should not treat them and their pointer (in Python heap) same as Python native types!Currently, this kind of too general conversion trait needs specialization and ... I'm not sure how to resolve this.
Honestly, I want to create a new trait for the 'In Python' layer in the above table, but it'll be a breaking change and careful design change.
https://github.com/PyO3/pyo3/blob/v0.8.4/src/types/sequence.rs#L248
It's a problem with speed and efficiency.
No technical problem is other than that.
The text was updated successfully, but these errors were encountered: