If you write Python loops, you can already write Mojo loops. The syntax is the same: for, while, break, continue.
To repeat something n times, use for _ in range(n):
Comprehensions work, too, i.e. [x * x for x in range(5)]
The biggest difference is speed. Mojo compiles your code, while Python interprets one step at a time.
We counted the primes below 2 million with the same trial-division loop in both languages (no sieve): Python took 2.8 seconds, Mojo took 57 ms.
More quick references in the Mojo cheat sheets: mojolang.org/docs/reference…
To repeat something n times, use for _ in range(n):
Comprehensions work, too, i.e. [x * x for x in range(5)]
The biggest difference is speed. Mojo compiles your code, while Python interprets one step at a time.
We counted the primes below 2 million with the same trial-division loop in both languages (no sieve): Python took 2.8 seconds, Mojo took 57 ms.
More quick references in the Mojo cheat sheets: mojolang.org/docs/reference…
Oct 23, 2026 · 5:08 PM UTC
4
7
104
3,742
@Modular I want a perfect programing language in AI era. please make MOJO general programing language and make the standard library Big enough to cover networking, io, json, file, time,crypto. please 🙏
1
0
1
54





