Mojo function
lookup_py_type_object
lookup_py_type_object[T: TypeIdentifiable]() -> TypedPythonObject[__init__[__mlir_type.!kgen.string]("Type")]
Retrieve a reference to the unique Python type describing Python objects containing Mojo values of type T
.
This function looks up the Python type object that was previously registered
for the Mojo type T
using a PythonTypeBuilder
. The returned type object
can be used to create Python objects that wrap Mojo values of type T
.
Parameters:
- T (
TypeIdentifiable
): The Mojo type to look up. Must implement theTypeIdentifiable
trait to provide a unique type identifier.
Returns:
A TypedPythonObject["Type"]
representing the Python type object that
binds the Mojo type T
to the current CPython interpreter instance.
Raises:
If no PythonTypeBuilder
was ever finalized for type T
, or if no
Python type object has been registered for the provided type identifier.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!