py_embed
library
Classes
PyBool
PyConverter
Converts Dart values to owned Python references.
PyDict
A Python dictionary. Keys and values are retained when inserted.
PyDouble
每次构造都会创建独立的 Python 浮点对象,即使值相同也不共享引用计数。
新对象的引用计数为 1,调用方需要分别释放各自的引用。
PyException
PyFunction
A Python callable backed by a synchronous Dart closure.
PyInt
CPython 会缓存小整数,相同的缓存值(例如 1)共享底层对象和引用计数。
这不代表所有整数都会共享;每次构造仍取得一个需要由调用方释放的引用。
引用计数的具体变化取决于 CPython 版本,不能假定每次构造都会加一。
PyList
PyModule
PyObject
PyObjectWrapper
A Dart object that holds a Python object by composition.
PyRef
One owned Python reference, automatically registered in the current scope.
PyString
PyTuple
tuple
ResourceScope
Automatic zone-based scoped resource manager for ScopedResource instances.
ScopedResource
An interface for resources (such as native FFI memory wrappers, file handles,
or external graphics/numerical buffers) that can be explicitly disposed
and automatically tracked by ResourceScope .
Functions
abs (PyObject object )
→ PyObject
Python abs(object), preserving custom Python return types.
ascii (PyObject object )
→ PyObject
divmod (PyObject a , PyObject b )
→ PyObject
Python divmod(a, b), preserving custom Python return types.
isInstance (PyObject object , PyObject classInfo )
→ bool
Python isinstance(object, classInfo), including tuples of types.
len (PyObject object )
→ int
Python len(object). Objects without a length raise TypeError.
newType (String name , List <PyObject > bases , Map <String , Object ? > attributes )
→ PyObject
Creates a class with name, bases, and attributes.
object ()
→ PyObject
Creates a Python object() instance owning a new reference.
pow (PyObject base , PyObject exponent , [PyObject ? modulus ])
→ PyObject
Python pow(base, exponent) or pow(base, exponent, modulus).
repr (PyObject object )
→ String
Python repr(object), copied into a Dart string.
runString (String code )
→ void
execute python code
str (PyObject object )
→ PyObject
superOf (PyObject type , PyObject object )
→ PyObject
Creates a Python super(type, object) proxy owning a new reference.
type (PyObject object )
→ PyObject
Returns the Python type of object.