[Feature Request] Re-enable `ConvertibleToPython` conformance for builtin types
Nobody has claimed this yet.
- Dominant language
- Mojo
- Stars
- 29.8k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
Review Mojo's priorities
- I have read the roadmap and priorities and I believe this request falls within the priorities.
What is your request?
Re-enabling ConvertibleToPython conformance for builtin types allows them to be used in generic code depending on ConvertibleToPython conformance.
What is your motivation for this change?
This was discussed on Discord with Chris and others.
https://discord.com/channels/1087530497313357884/1503501113217781810
It is appealing to me because it is cleaner and less arbitrary, but it does mix more python stuff into standard files. It is probably the cleanest solution though.
All this stuff will be much cleaner with extensions! 🙂
In any case, I support # 2 if you think this would help. Would you be willing to put up a PR?
Changes:
- Remove implicit init methods on PythonObject for the builtin types (
Bool,Int,Skalar,StringLiteral,StringSliceandString). - Add trait
ConvertibleToPythonto those types. This still allows for implicit conversion toPythonObject. - Add unit tests to check
ConvertibleToPythonconformance and implicit conversion - Aligns builtin types with custom types as both use the same implicit
PythonObjectinit method.
As discussed with Chris I will open a PR for this change.
Any other details?
This is related to [mojo-stdlib] 3/x: Continue simplifying PythonObject implementation · modular/modular@5a23c2a where conformance to ConvertibleToPython was removed from builtin types to enable implicit conversion to PythonObject for custom types conforming to ConvertibleToPython.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the builtin type definitions for Bool, Int, Skalar, StringLiteral, StringSlice, and String, along with the PythonObject and ConvertibleToPython implementations. Review the related unit-test area before making changes. Done means the listed types conform to ConvertibleToPython, implicit PythonObject conversion remains covered, and the unit tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100