object
Defines the object type, which is used to represent untyped values.
These are Mojo built-ins, so you don’t need to import them.
Attr
A generic object’s attributes are set on construction, after which the attributes can be read and modified, but no attributes may be removed or added.
Fields:
-
key (
StringLiteral
): The name of the attribute. -
value (
object
): The value of the attribute.
Implemented traits:
AnyType
Methods:
__init__
__init__(inout self: Self, key: StringLiteral, owned value: object)
Initializes the attribute with a key and value.
Args:
- key (
StringLiteral
): The string literal key. - value (
object
): The object value of the attribute.
object
Represents an object without a concrete type.
This is the type of arguments in def
functions that do not have a type annotation, such as the type of x
in def f(x): pass
. A value of any type can be passed in as the x
argument in this case, and so that value is used to construct this object
type.
Aliases:
-
nullary_function = fn() raises -> object
: Nullary function type. -
unary_function = fn(object) raises -> object
: Unary function type. -
binary_function = fn(object, object) raises -> object
: Binary function type. -
ternary_function = fn(object, object, object) raises -> object
: Ternary function type.
Implemented traits:
AnyType
, Boolable
, IntableRaising
, Stringable
Methods:
__init__
__init__(inout self: Self)
Initializes the object with a None
value.
__init__(inout self: Self, impl: _ObjectImpl)
Initializes the object with an implementation value. This is meant for internal use only.
Args:
- impl (
_ObjectImpl
): The object implementation.
__init__(inout self: Self, none: None)
Initializes a none value object from a None
literal.
Args:
- none (
None
): None.
__init__(inout self: Self, value: Int)
Initializes the object with an integer value.
Args:
- value (
Int
): The integer value.
__init__(inout self: Self, value: SIMD[f64, 1])
Initializes the object with an floating-point value.
Args:
- value (
SIMD[f64, 1]
): The float value.
__init__[dt: DType](inout self: Self, value: SIMD[dt, 1])
Initializes the object with a generic scalar value. If the scalar value type is bool, it is converted to a boolean. Otherwise, it is converted to the appropriate integer or floating point type.
Parameters:
- dt (
DType
): The scalar value type.
Args:
- value (
SIMD[dt, 1]
): The scalar value.
__init__(inout self: Self, value: Bool)
Initializes the object from a bool.
Args: