Interoperability of mojo Traits and Python protocols #1653
Locked
strangemonad
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm really excited to see the first pass of traits land in the language. I know there's still much to flesh out but one place that I think might be interesting to flesh out sooner rather than later is how traits and protocols are able to interoperate.
I feel like the python community is starting to converge and collectively understand the value of capturing interfaces as code rather than just documentation. Many popular libraries are exposing
Protocols
. There are also starting to be cross-project efforts like the dataframe interchange protocol https://data-apis.org/dataframe-protocol/latest/index.html. It's exciting to see this level of iterop maturity taking form in the python community given that most of the historical interop story has revolved around documenting and runtime checking the presence of certain fields and methods.I think mojo could be a catalyst in continuing that discussion. The development of the mojo std lib might also benefit if it's grounded in a discussion around some minimal interoperability between traits and protocols (e.g. things like Stringable, Readable, Writable, Seekable, Sized, Countable...)
My open-ended question has 2 parts. I understand that traits and protocols are not 1-1 alike but it would be insightful to capture what aspects are meant to be compatible.
@property
methods, maybe there's a subset of protocols, like function-only protocols, that a trait can conform to?Beta Was this translation helpful? Give feedback.
All reactions