Martin Vuyk
MModular
•Created by toasty on 12/18/2024 in #questions
Is it possible to get the origin of `strs` in `fn name(*strs: String)`?
Thanks a lot 😄 . My goal is to make it feel like Python in that sense. It's one of the things I love most about it
19 replies
MModular
•Created by toasty on 12/18/2024 in #questions
Is it possible to get the origin of `strs` in `fn name(*strs: String)`?
I want to introduce a lazy iterator over splitlines
19 replies
MModular
•Created by toasty on 12/18/2024 in #questions
Is it possible to get the origin of `strs` in `fn name(*strs: String)`?
you might want to copy some code from this PR
19 replies
MModular
•Created by toasty on 12/18/2024 in #questions
Is it possible to get the origin of `strs` in `fn name(*strs: String)`?
yep, I know that's a very common use case
19 replies
MModular
•Created by toasty on 12/18/2024 in #questions
Is it possible to get the origin of `strs` in `fn name(*strs: String)`?
actually it should also remove the need for the shady casting
ImmutableOrigin.cast_from[__origin_of(items)].result
19 replies
MModular
•Created by toasty on 12/18/2024 in #questions
Is it possible to get the origin of `strs` in `fn name(*strs: String)`?
yeah not very adviced to the general public but I know you want to get other things done lol
19 replies
MModular
•Created by toasty on 12/18/2024 in #questions
Is it possible to get the origin of `strs` in `fn name(*strs: String)`?
well probably the
VariadicList
is a union of the origins now that I think about it19 replies
MModular
•Created by toasty on 12/18/2024 in #questions
Is it possible to get the origin of `strs` in `fn name(*strs: String)`?
I have a PR open on nightly which should remove the need for
rebind[S](s[].as_string_slice()).splitlines()
19 replies
MModular
•Created by toasty on 12/18/2024 in #questions
Is it possible to get the origin of `strs` in `fn name(*strs: String)`?
basically this is the hacky way of binding the origin to the list of strings itself
19 replies
MModular
•Created by toasty on 12/18/2024 in #questions
Is it possible to get the origin of `strs` in `fn name(*strs: String)`?
Now, what I like about Mojo is that you can point a 🔫 to the compiler's head and say "trust me bro":
19 replies
MModular
•Created by toasty on 12/18/2024 in #questions
Is it possible to get the origin of `strs` in `fn name(*strs: String)`?
Hey @toasty cool to see my code being used in ways I never imagined 🤣 . No that won't work, you're trying to use the origin of the
VariadicList
as the origin of the strings themselves. This is a hard limitation of our current origin system, you can't have a heterogeneous list which is what this would need to be to be able to carry the origin of each of the strings inside the VariadicList
.19 replies
MModular
•Created by aurelian on 10/19/2024 in #questions
Not sure why these strings are missing the last char
I'm hoping to land this before the next stable release in 2025 but we'll see
24 replies
MModular
•Created by aurelian on 10/19/2024 in #questions
Not sure why these strings are missing the last char
100%, I'm leaving that off to the future because I'm waiting until I can make the switch to full unicode to not break too much code. The current String type is sliced by bytes, but Python's is by unicode codepoints. The current
len(String)
also returns byte_length()
instead of unicode codepoint length, Python's is unicode codepoints. len(StringSlice)
works by unicode codepoints, so adding slicing will confuse many people.24 replies
MModular
•Created by aurelian on 10/19/2024 in #questions
Not sure why these strings are missing the last char
Oh yeah that's totally in the roadmap. Once we have a Bytes type defined we'll have Bytes.decode() (or something of the like). At least it's my hope to be able to implement it and it getting merged 😄
24 replies
MModular
•Created by aurelian on 10/19/2024 in #questions
Not sure why these strings are missing the last char
So there is no way to "safely" get data from the wire were you're sure it's valid UTF-8 from a generic API perspective
24 replies
MModular
•Created by aurelian on 10/19/2024 in #questions
Not sure why these strings are missing the last char
It's only unsafe in the sense that you don't know if the data is valid UTF-8 (and StringSlice is supposed to always be valid UTF-8. The constructor should have a debug_assert(_is_valid_utf8(span)) but there are issues with the function at compile time so it's not active.
24 replies
MModular
•Created by Tyler Hillery on 12/4/2024 in #questions
1 Billion nested loop iterations Mojo Implementation - seeking feedback
I still think these are awesome results ( speaking as a python dev )That's one of the main goals, providing a simple to use language where the default is high performance and the option to go deeper is always there. Your code wasn't that much different in performance to the end result for example 🙂
67 replies
MModular
•Created by Tyler Hillery on 12/4/2024 in #questions
1 Billion nested loop iterations Mojo Implementation - seeking feedback
It's fine by me either way, I still think its too early for Mojo to start being compared since we are still changing much of the stdlib and figuring stuff out.
67 replies
MModular
•Created by Tyler Hillery on 12/4/2024 in #questions
1 Billion nested loop iterations Mojo Implementation - seeking feedback
I'm mostly guessing, but this line
u = int(sys.argv()[1]) # Get an input number from the command line
triggers atol
which has a lot of logic that has to deal with a lot of edge cases which are only true to comply with Python. I'm not sure if that has enough impact for this difference though67 replies
MModular
•Created by Tyler Hillery on 12/4/2024 in #questions
1 Billion nested loop iterations Mojo Implementation - seeking feedback
That would put us around 13th place if we assume both CPUs have similar SIMD capabilities (which I think it's safe to assume since both are M3 and took around the same time)
67 replies