Mojo function
size_of
size_of[type: AnyType, target: target = _current_target()]() -> Int
Returns the size of (in bytes) of the type.
Example:
from sys.info import size_of
def main():
print(
size_of[UInt8]() == 1,
size_of[UInt16]() == 2,
size_of[Int32]() == 4,
size_of[Float64]() == 8,
size_of[
SIMD[DType.uint8, 4]
]() == 4,
)
Note: align_of
is in same module.
Parameters:
- type (
AnyType
): The type in question. - target (
target
): The target architecture.
Returns:
Int
: The size of the type in bytes.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!