Documentation
¶
Index ¶
- Constants
- func Finalize()
- func Initialize()
- func InitializeEx(initsigs c.Int)
- func RunSimpleFile(fp c.FilePtr, filename *c.Char) c.Int
- func RunSimpleFileFlags(fp c.FilePtr, filename *c.Char, flags *CompilerFlags) c.Int
- func RunSimpleString(command *c.Char) c.Int
- func RunSimpleStringFlags(command *c.Char, flags *CompilerFlags) c.Int
- func SetProgramName(name *c.Char)
- type CompilerFlags
- type InputType
- type Object
- func BuildValue(format *c.Char, __llgo_va_list ...any) *Object
- func CompileString(str, filename *c.Char, start InputType) *Object
- func CompileStringExFlags(str, filename *c.Char, start InputType, flags *CompilerFlags, optimize c.Int) *Object
- func CompileStringFlags(str, filename *c.Char, start InputType, flags *CompilerFlags) *Object
- func CompileStringObject(str *c.Char, filename *Object, start InputType, flags *CompilerFlags, ...) *Object
- func EvalCode(code, globals, locals *Object) *Object
- func EvalCodeEx(code, globals, locals *Object, args *Object, argcount c.Int, kws *Object, ...) *Object
- func Float(v float64) *Object
- func FloatFromSring(v *Object) *Object
- func FromCStr(s *c.Char) *Object
- func FromString(s string) *Object
- func Import(name *Object) *Object
- func ImportModule(name *c.Char) *Object
- func (o *Object) CStr() *c.Char
- func (o *Object) Call(args, kwargs *Object) *Object
- func (o *Object) CallFunction(format *c.Char, __llgo_va_list ...any) *Object
- func (o *Object) CallFunctionObjArgs(__llgo_va_list ...any) *Object
- func (o *Object) CallMethod(name *c.Char, format *c.Char, __llgo_va_list ...any) *Object
- func (o *Object) CallMethodNoArgs(name *Object) *Object
- func (o *Object) CallMethodObjArgs(name *Object, __llgo_va_list ...any) *Object
- func (o *Object) CallMethodOneArg(name, arg *Object) *Object
- func (o *Object) CallNoArgs() *Object
- func (o *Object) CallObject(callable, args *Object) *Object
- func (o *Object) CallOneArg(arg *Object) *Object
- func (o *Object) Callable() c.Int
- func (o *Object) DecRef()
- func (o *Object) Float64() float64
- func (o *Object) GetAttr(attrName *Object) *Object
- func (o *Object) GetAttrString(attrName *c.Char) *Object
- func (m *Object) ModuleGetDict() *Object
- func (m *Object) ModuleLoadSyms(__llgo_va_list ...any)
- func (o *Object) Strlen() uintptr
- func (o *Object) Vectorcall(args **Object, nargs uintptr, kwnames *Object) *Object
- func (o *Object) VectorcallDict(args **Object, nargs uintptr, kwdict *Object) *Object
- func (o *Object) VectorcallMethod(name *Object, args **Object, nargs uintptr, kwnames *Object) *Object
Constants ¶
const (
LLGoPackage = "link: $LLGO_LIB_PYTHON"
)
Variables ¶
This section is empty.
Functions ¶
func Initialize ¶
func Initialize()
func InitializeEx ¶
This function works like Initialize() if initsigs is 1. If initsigs is 0, it skips initialization registration of signal handlers, which might be useful when Python is embedded.
func RunSimpleFileFlags ¶
func RunSimpleStringFlags ¶
func RunSimpleStringFlags(command *c.Char, flags *CompilerFlags) c.Int
func SetProgramName ¶
Types ¶
type Object ¶
type Object struct {
Unused [8]byte
}
Object represents a Python object.
func BuildValue ¶
Create a new value based on a format string similar to those accepted by the PyArg_Parse* family of functions and a sequence of values. Returns the value or nil in the case of an error; an exception will be raised if nil is returned. See https://docs.python.org/3/c-api/arg.html#c.Py_BuildValue
func CompileStringExFlags ¶
func CompileStringFlags ¶
func CompileStringFlags(str, filename *c.Char, start InputType, flags *CompilerFlags) *Object
func CompileStringObject ¶
func CompileStringObject(str *c.Char, filename *Object, start InputType, flags *CompilerFlags, optimize c.Int) *Object
Parse and compile the Python source code in str, returning the resulting code object. The start token is given by start; this can be used to constrain the code which can be compiled and should be py.EvalInput, py.FileInput, or py.SingleInput. The filename specified by filename is used to construct the code object and may appear in tracebacks or SyntaxError exception messages. This returns NULL if the code cannot be parsed or compiled.
The integer optimize specifies the optimization level of the compiler; a value of -1 selects the optimization level of the interpreter as given by -O options. Explicit levels are 0 (no optimization; __debug__ is true), 1 (asserts are removed, __debug__ is false) or 2 (docstrings are removed too).
func EvalCode ¶
This is a simplified interface to EvalCodeEx, with just the code object, and global and local variables. The other arguments are set to nil.
func EvalCodeEx ¶
func EvalCodeEx( code, globals, locals *Object, args *Object, argcount c.Int, kws *Object, kwcount c.Int, defs *Object, defcount c.Int, kwdefs, closure *Object) *Object
Evaluate a precompiled code object, given a particular environment for its evaluation. This environment consists of a dictionary of global variables, a mapping object of local variables, arrays of arguments, keywords and defaults, a dictionary of default values for keyword-only arguments and a closure tuple of cells.
func FloatFromSring ¶
func FromString ¶
FromString returns a new bytes object from a Go string.
func Import ¶
This is a higher-level interface that calls the current “import hook function” (with an explicit level of 0, meaning absolute import). It invokes the __import__() function from the __builtins__ of the current globals. This means that the import is done using whatever import hooks are installed in the current environment.
This function always uses absolute imports.
func ImportModule ¶
This is a wrapper around py.Import which takes a const char* as an argument instead of an Object.
func (*Object) CStr ¶
CStr returns the content of a bytes object as a C string.
llgo:link (*Object).CStr C.PyBytes_AsString
func (*Object) Call ¶
Call a callable Python object o, with arguments given by the tuple args, and named arguments given by the dictionary kwargs.
args must not be nil; use an empty tuple if no arguments are needed. If no named arguments are needed, kwargs can be nil.
Return the result of the call on success, or raise an exception and return nil on failure.
This is the equivalent of the Python expression: o(*args, **kwargs).
llgo:link (*Object).Call C.PyObject_Call
func (*Object) CallFunction ¶
Call a callable Python object o, with a variable number of C arguments. The C arguments are described using a py.BuildValue style format string. The format can be nil, indicating that no arguments are provided.
Return the result of the call on success, or raise an exception and return nil on failure.
This is the equivalent of the Python expression: o(*args).
Note that if you only pass PyObject* args, (*Object).CallFunctionObjArgs is a faster alternative.
llgo:link (*Object).CallFunction C.PyObject_CallFunction
func (*Object) CallFunctionObjArgs ¶
Call a callable Python object o, with a variable number of PyObject* arguments. The arguments are provided as a variable number of parameters followed by nil.
Return the result of the call on success, or raise an exception and return nil on failure.
This is the equivalent of the Python expression: o(arg1, arg2, ...).
llgo:link (*Object).CallFunctionObjArgs C.PyObject_CallFunctionObjArgs
func (*Object) CallMethod ¶
llgo:link (*Object).CallMethod C.PyObject_CallMethod
func (*Object) CallMethodNoArgs ¶
llgo:link (*Object).CallMethodNoArgs C.PyObject_CallMethodNoArgs
func (*Object) CallMethodObjArgs ¶
llgo:link (*Object).CallMethodObjArgs C.PyObject_CallMethodObjArgs
func (*Object) CallMethodOneArg ¶
llgo:link (*Object).CallMethodOneArg C.PyObject_CallMethodOneArg
func (*Object) CallNoArgs ¶
Call a callable Python object callable without any arguments. It is the most efficient way to call a callable Python object without any argument.
Return the result of the call on success, or raise an exception and return nil on failure.
llgo:link (*Object).CallNoArgs C.PyObject_CallNoArgs
func (*Object) CallObject ¶
Call a callable Python object o, with arguments given by the tuple args. If no arguments are needed, then args can be nil.
Return the result of the call on success, or raise an exception and return nil on failure.
This is the equivalent of the Python expression: o(*args).
llgo:link (*Object).CallObject C.PyObject_CallObject
func (*Object) CallOneArg ¶
Call a callable Python object callable with exactly 1 positional argument arg and no keyword arguments.
Return the result of the call on success, or raise an exception and return nil on failure.
llgo:link (*Object).CallOneArg C.PyObject_CallOneArg
func (*Object) Callable ¶
Determine if the object o is callable. Return 1 if the object is callable and 0 otherwise. This function always succeeds.
llgo:link (*Object).Callable C.PyCallable_Check
func (*Object) GetAttr ¶
Retrieve an attribute named attrName from object o. Returns the attribute value on success, or nil on failure. This is the equivalent of the Python expression o.attrName.
llgo:link (*Object).GetAttr C.PyObject_GetAttr
func (*Object) GetAttrString ¶
llgo:link (*Object).GetAttrString C.PyObject_GetAttrString
func (*Object) ModuleGetDict ¶
Return the dictionary object that implements module’s namespace; this object is the same as the __dict__ attribute of the module object. If module is not a module object (or a subtype of a module object), SystemError is raised and nil is returned.
It is recommended extensions use other Module and Object functions rather than directly manipulate a module’s __dict__.
llgo:link (*Object).ModuleGetDict C.PyModule_GetDict
func (*Object) ModuleLoadSyms ¶
llgo:link (*Object).ModuleLoadSyms C.llgoLoadPyModSyms
func (*Object) Vectorcall ¶
llgo:link (*Object).Vectorcall C.PyObject_Vectorcall
func (*Object) VectorcallDict ¶
llgo:link (*Object).VectorcallDict C.PyObject_VectorcallDict