v25.5 (2025-08-05)
✨ Highlights
-
Mojo is now available independently as the
mojoConda package. In includes the Mojo compiler, standard library, and thelayoutpackage (which is heavily used in GPU programming). It also includes the Mojo developer tools: LSP, debugger, formatter, and so on.To use Python to Mojo interoperability in v25.5, you must install the
modularpackage. This will move to themojopackage in a future release.For more details, see the install guide.
-
Parametric aliases are now supported: Aliases can be specified with an optional parameter list (just like functions). Parametric aliases are considered first class parameter values, too. For more details, see Parametric aliases in the Mojo Manual.
-
Mojo API documentation now generates cross-references for parameter, argument, and return value types.
Language enhancements
-
@parameter fornow works on a broader range of collection types, enabling things like@parameter for i in [1, 2, 3]: .... -
StringLiteralnow automatically materializes to aStringwhen used at runtime:alias param = "foo" # type = StringLiteral
var runtime_value = "bar" # type = String
var runtime_value2 = param # type = StringThis enables all the behavior users expect without having to convert or annotate types, for example:
var string = "hello"
string += " world"
var if_result = "foo" if True else "bar"Initializing a
Stringfrom aStringLiteralinitially points to static constant memory, and does not perform any allocation until the first mutation. -
The compiler now detects attempts to materialize references to compile-time interpreter stack memory into runtime code. This includes related types that reference memory, like slices, spans, and pointers.
The compiler cannot currently track the lifetime of internal stack objects when materialized to runtime, which could cause memory leaks. Consider this example:
fn test_comptime_materialize():
# This is ok! Forms a comptime pointer to a comptime "stack" value of
# String type.
alias comptime_ptr = String("foo" + "bar").unsafe_ptr()
# This is ok too, dereferences the pointer at comptime, loading the byte.
alias byte = comptime_ptr[]
# This materializes a Byte from comptime to runtime.
var rt_byte = byte
# Error: cannot materialize to runtime value, the type contains an origin
# referring to a compile-time value
var bad_usage = comptime_ptrPreviously the compiler would materialize the memory representation of the
Stringvalue but not know it needs to be destroyed. It now detects the problem. If you run into this, rework the code to materialize the full object (e.g. the String) to runtime explicitly:alias comptime_string = String("foo" + "bar")
var runtime_string = comptime_string
Language changes
-
The
@valuedecorator has been formally deprecated with a warning, it will be removed in the next release of Mojo. Please move to the@fieldwise_initand synthesizedCopyableandMovabletrait conformance. -
Implicit trait conformance is removed. All conformances must be explicitly declared.
-
The
ownedargument convention is being renamed tovar. This reflects thatvaris used consistently for a "named, scoped, owned value" already which is exactly what theownedconvention does. In this release, bothvarandownedare allowed in an argument list, butownedwill be removed in a subsequent release, so please move your code over. -
Function overloading is now fully supported as long as, among two function signatures with the same list of argument types, one position is a keyword-only argument in at least one signature, and that position differs in argument name. Previously an edge case prevented this support when the return types are different. For example, these two functions can now co-exist:
fn get(self, idx: Int) -> Int
fn get(self, *, idx2: Int) -> Float32
Standard library changes
-
Indexing into a
Stringnow returns aStringSlice, avoiding an allocation.String.split()now returns aList[StringSlice]. -
Added support for a wider range of consumer-grade AMD hardware, including:
- AMD Radeon RX 7xxx GPUs
- AMD Radeon RX 9xxx GPUs
-
Compile-time checks for AMD RDNA3+ GPUs are now provided by the following functions (which can be imported from
sys.info):_is_amd_rdna3()_is_amd_rdna4()_is_amd_rdna()
-
Added WMMA matrix-multiplication instructions for RDNA3+ GPUs to help support running AI models on those GPUs.
-
Added support for NVIDIA GeForce RTX 3090.
-
memory.UnsafePointeris now implicitly included in all mojo files. Moreover,OpaquePointer(the equivalent of avoid*in C) is moved into thememorymodule, and is also implicitly included. -
Python interop changes:
-
Mojo methods can now take
py_self: UnsafePointer[Self]instead of the rawpy_self: PythonObject, eliminating the downcasting boilerplate required in the common case. -
Mojo functions can now natively accept keyword arguments from Python using
OwnedKwargsDict[PythonObject]as the last parameter. This enables direct calling from Python with keyword arguments without requiring wrapper functions.from collections import OwnedKwargsDict
# Callable from Python as `foo(10, y=20)`
fn foo(x: PythonObject, kwargs: OwnedKwargsDict[PythonObject]):
y = kwargs["y"] -
The
PythonTypeBuilderutility now allows:- Registering bindings for Python static methods, i.e. methods that don't require an instance of the class.
- Registering initializers that take arguments. Types no longer need to be
Defaultableto be exposed and created from Python.
-
The
PythonConvertibletrait has been renamed toConvertibleToPython. This is now consistent with theConvertibleFromPythontrait, modeling Mojo types that can be converted either to or from aPythonObject.
For more information, see Calling Mojo from Python in the Mojo Manual.
-
-
Added
Iteratortrait for modeling types that produce a sequence of values.A type can implement
Iteratorby providing__next__()and__has_next__()methods. This naming and behavior is based on the PythonIteratortype annotation, diverging slightly due to constraints present in Mojo today.Any type that implements
Iteratorcan be used withinforand@parameter forlooping syntax.Iteratordoes not currently have a variant for supporting iteration over borrowedrefvalues. -
The
Dicttype now has anHparameter which allows users to provider a customHashertype.default_hasher(AHasher) anddefault_comp_time_hasher(Fnv1a) are now provided- The
Hparameter ofDictdefaults todefault_hasher
-
The
Hashabletrait has been updated to use a new data flow strategy.- Users are now required to implement the method
fn __hash__[H: Hasher](self, mut hasher: H):(see theHashableAPI documentation for further details).
- Users are now required to implement the method
-
InlineArraycan now be constructed with a size of 0. This makes it easier to useInlineArrayin situations where the number of elements is generic and could also be 0. -
List.append(Span)has been renamed toList.extend(Span). It is important for readability and consistency thatappend()always grows the length of the list by exactly 1.extend()in both Python and Rust is the variant of this operation that takes an arbitrary-length number of additional elements (possibly 0) to add to the list. -
A new
iomodule is available in the library. Some core input/output APIs previously in thebuiltinmodule have been moved toio. Currently all of the APIs in theiomodule are imported automatically. The following APIs were moved toio:- File-related APIs such as
open(),FileHandleandFileDescriptor. - The
WriterandWritabletraits. input()andprint()functions.
- File-related APIs such as
-
StringLiteral.strip()family of functions now return aStaticString.
Tooling changes
-
Added support for GCC-style debug flags
-g0,-g1, and-g2to match common compiler conventions:-g0: No debug information (alias for--debug-level=none).-g1: Line table debug information (alias for--debug-level=line-tables).-g2: Full debug information (alias for--debug-level=full).
-
Added progress reporting support to the Mojo language server. This will emit progress notifications in your editor when the server is currently parsing a document.
❌ Removed
-
Various functions from the
sys.infopackage have been moved to thesys.info.CompilationTargetstruct:is_x86()has_sse4()has_avx()has_avx2()has_avx512f()has_fma()has_vnni()has_neon()has_neon_int8_dotprod()has_neon_int8_matmul()
-
UnsafePointer.address_of()has been removed. UseUnsafePointer(to=...)constructor instead. Similarly,Pointer.address_of()has been removed. -
DType.tensor_float32has been removed due to lack of support for it in the library and the compiler.
🛠️ Fixed
-
#4121 - better error message for
.value()on emptyOptional. -
#4566 - Hang when assigning loop variable inside
@parameter for. -
#4820 -
math.exp2picks the wrong implementation forfloat64. -
#4836 - Else path in
@parameter forbroken. -
#4499 - Traits with
ref selfcause issues when used as parameter. -
#4911 -
InlineArraynow calls the move constructor for its elements when moved. -
#3927 -
InlineArraynow can be constructed with a size of 0. -
#4954 -
InlineArraynow does not call the copy constructor when being moved. -
#5066 - Correctly fill 64-bit values on AMD in
enqueue_fill. -
#4982 - Add
toggle_alltoBitSet. -
#5086 - Add
set_alltoBitSet. -
#5057 - Span Performance Regression.
-
#5051 - Incorrect
.modularDirectory Location on Linux. -
#5021 - LSP Crashes in VSCode when a local package exists.
-
#5016 - Conditional Conformance Trait Alias Bug.
Special thanks
Special thanks to our community contributors:
@zsiegel92, @yeison, @soraros, @samufi, @mzaks, @mmicu, @martinvuyk, @hardikkgupta, @gustawdaniel, @cyrillzadra, @cnhz95, @christoph-schlumpf, @bgreni, @benz0li, @LeeLee26, @Caslyn, @Amila-Rukshan, @Amet13, and @AceMouse.