Expand description
Standard Python Runtime Library for Rython
This library provides all the built-in functions, types, and methods that are available in Python without any imports. It serves as the runtime foundation for Python code compiled to Rust using python-ast-rs.
§Features
std
(default): Full standard library support with I/O operationsnostd
: No-std compatible version for embedded systems
Re-exports§
pub use stdlib::sys;
pub use stdlib::os;
pub use stdlib::subprocess;
Modules§
- stdlib
- Python Standard Library modules Python Standard Library Implementation
Structs§
- PyAny
- Represents any Python object.
- PyDictionary
- Python-style dictionary type with all dict methods
- PyException
- Base class for all Python exceptions
- PyFile
- Python file object
- PyList
- Python-style list type with all list methods
- PySet
- Python-style set type with all set methods
- PyStr
- Python-style string type with all string methods
- PyTuple
- Python-style tuple type
Constants§
Traits§
- AsArg
List - Trait for collections that can be used as argument lists
- AsEnv
Like - Trait for environment-like collections (key-value pairs)
- AsPath
Like - Trait for types that can be used as path-like parameters
- AsStr
Like - Trait for types that can be used as string-like parameters
- Into
Owned String - Trait for types that can be converted to owned strings
- Len
- Trait for objects that have a length
- PyAbs
- Trait for types that support absolute value
- PyBool
- Trait for Python-style boolean conversion
- PyFloat
- Trait for Python-style float conversion
- PyInt
- Trait for Python-style integer conversion
- PySum
- Trait for types that can be summed
- PyTo
String - Trait for Python-style string conversion
- Truthy
- Trait for objects that can be evaluated for truthiness
Functions§
- abs
- Python abs() function - returns absolute value
- all
- Python all() function - returns True if all elements are truthy
- any
- Python any() function - returns True if any element is truthy
- attribute_
error - Python AttributeError
- bool
- Python bool() function - converts to boolean
- dict
- Python dict() function - creates a new dictionary (generic version)
- dict_
from_ pairs - Simplified dict creation from key-value pairs
- dict_
with_ env - Python dict() function with environment merging (generic version)
- ensure_
venv_ ready - Placeholder for ensure_venv_ready function (from pyperformance or similar) This is not a standard Python built-in, so we provide a stub that returns dummy values
- enumerate
- Python enumerate() function - returns iterator with index and value pairs
- enumerate_
slice - Helper for enumerate() function with slice input - returns pairs of (index, reference)
- float
- Python float() function - converts to float
- format_
string - Helper for string formatting (common in f-strings compilation)
- index_
error - Python IndexError
- input
- Python input() function - reads input from user
- int
- Python int() function - converts to integer
- key_
error - Python KeyError
- len
- Python len() function - returns the length of an object
- list_
contains - Helper for in/not in operations on lists
- max
- Python max() function
- min
- Python min() function
- multiply_
list - Helper for Python-style list multiplication
- multiply_
string - Helper for Python-style string multiplication
- name_
error - Python NameError
- open
- Python open() function - opens a file
- overflow_
error - Python OverflowError
- Python print() function - outputs objects to stdout with optional separator and ending
- print_
args - Python print() function with multiple arguments
Note: Only available with
std
feature - requires OS I/O capabilities - py_dict
- Helper function for dictionary creation (common in compiled code)
- py_list
- Helper function for list creation from Rust vectors (common in compiled code)
- py_set
- Helper function for set creation (common in compiled code)
- py_
tuple - Helper function for tuple creation (common in compiled code)
- range
- Python range() function - generates sequence of numbers
- range_
flexible - Helper for range() function with optional parameters - more flexible than the basic range
- range_
start_ stop - range_
start_ stop_ step - runtime_
error - Python RuntimeError
- slice
- Helper for Python-style slicing
- str
- Python str() function - converts to string
- string_
contains - Helper for in/not in operations on strings
- sum
- Python sum() function
- type_
error - Python TypeError
- value_
error - Python ValueError
- zero_
division_ error - Python ZeroDivisionError
- zip
- Python zip() function - combines multiple iterables
- zip_
slices - Helper for zip() function with slice inputs - combines two iterables with lifetimes
Type Aliases§
- PyObject
- A commonly-used alias for
Py<PyAny>
.