-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[stlib] String conversion of list literals and lists with representable items #3521
base: main
Are you sure you want to change the base?
Conversation
To improve the ergonomics of the Mojo language for Python developers. Signed-off-by: Manuel Saelices <[email protected]>
Signed-off-by: Manuel Saelices <[email protected]>
Signed-off-by: Manuel Saelices <[email protected]>
Signed-off-by: Manuel Saelices <[email protected]>
Signed-off-by: Manuel Saelices <[email protected]>
Signed-off-by: Manuel Saelices <[email protected]>
…ith MLIR types Signed-off-by: Manuel Saelices <[email protected]>
cc5f8aa
to
f836400
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thank you!
@@ -16,7 +16,10 @@ from testing import assert_equal | |||
|
|||
|
|||
def test_str_none(): | |||
assert_equal(str(None), "None") | |||
# TODO(#3393): Change to str(None) when MLIR types do not confuse overload resolution. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question Is this still valid since we have NoneType
in the stdlib
now? We could give the conformance of RepresentableCollectionElement
to it and the previous code may "just work"?
writer.write(", ") | ||
|
||
@parameter | ||
if _type_is_eq[T, PythonObject](): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jackos would this sort of thing able to be improved with your in-flight PR for writer? I don't love explicitly enumerating a bunch of types that we know are convertible to writable since we just store a Tuple[*Ts]
and don't know if the Ts
are writable themselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we need Mojo properly condicional conformance support, or at least to have a _implements()
logic (see #3630) to be able to make this work without enumerating a bunch of types. This is the only workaround I know, and this is also used by @martinvuyk in the DType.get_type()
implementation (see #3810)
To improve the ergonomics of the Mojo language for Python developers: