6. Type Conversions
When using annotations like @[py_module_fn] or
@[py_module_attr], Nerodia constructs a Python signature from the Lean
definition's signature, translating the Lean types of arguments and results
into Python types. In the simple case, a Nerodia type representing a Python type
(e.g., PyBool) is translated directly to its corresponding Python type.
Standard Lean types (e.g., Bool), on the other hand, require conversion,
and Nerodia follows the mapping below in doing so.
Lean Type | Python Argument Type | Python Result Type |
|---|---|---|
| — |
|
| — |
|
| — |
|
| — |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
|
-
IntX, fixed-width integers:ISize,Int64,Int32,Int16,Int8 -
UIntX, fixed-width unsigned integers:USize,UInt64,UInt32,UInt16,UInt8