package
0.9.6
Repository: https://github.com/goplus/llgo.git
Documentation: pkg.go.dev

# README

Linking Python to Go

TODO

Demo

The _demo directory contains our demos (it start with _ to prevent the go command from compiling it):

  • hellopy: link Python to Go and say Hello world
  • clpy: compile Python code and eval.
  • callpy: call Python standard library function math.sqrt.

How to run demos

To run the demos in directory _demo, you need to set the LLGO_LIB_PYTHON environment variable first. Assuming you use Python 3.12, and the libpython3.12.so (or libpython3.12.dylib or python3.12.lib) file is in the /foo/bar directory, then you need to set LLGO_LIB_PYTHON to:

export LLGO_LIB_PYTHON=/foo/bar/python3.12

For example, /opt/homebrew/Frameworks/Python.framework/Versions/3.12/lib/libpython3.12.dylib is a typical python lib location under macOS. So we should set it like this:

export LLGO_LIB_PYTHON=/opt/homebrew/Frameworks/Python.framework/Versions/3.12/lib/python3.12

Then you can run the demos in directory _demo:

cd <demo-directory>  # eg. cd _demo/hellopy
llgo run .

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

Return the module object corresponding to a module name.
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.
go:linkname CompileString C.Py_CompileString.
go:linkname CompileStringExFlags C.Py_CompileStringExFlags.
go:linkname CompileStringFlags C.Py_CompileStringFlags.
Parse and compile the Python source code in str, returning the resulting code object.
Clear the error indicator.
go:linkname ErrPrint C.PyErr_Print.
This is a simplified interface to EvalCodeEx, with just the code object, and global and local variables.
Evaluate a precompiled code object, given a particular environment for its evaluation.
go:linkname Finalize C.Py_Finalize.
go:linkname Float C.PyFloat_FromDouble.
go:linkname FloatFromSring C.PyFloat_FromString.
go:linkname FromCStr C.PyUnicode_FromString.
go:linkname FromCStrAndLen C.PyUnicode_FromStringAndSize.
FromGoString returns a new Unicode object from a Go string.
This is a higher-level interface that calls the current “import hook function” (with an explicit level of 0, meaning absolute import).
This is a wrapper around py.Import which takes a const char* as an argument instead of an Object.
go:linkname Initialize C.Py_Initialize.
This function works like Initialize() if initsigs is 1.
go:linkname List llgo.pyList.
go:linkname Long C.PyLong_FromLong.
go:linkname LongFromCStr C.PyLong_FromString.
go:linkname LongFromFloat64 C.PyLong_FromDouble.
go:linkname LongFromUnicode C.PyLong_FromUnicodeObject.
go:linkname LongFromVoidPtr C.PyLong_FromVoidPtr.
go:linkname LongLong C.PyLong_FromLongLong.
Return a new empty dictionary, or nil on failure.
Return a new function object associated with the code object code.
As NewFunc, but also allows setting the function object’s __qualname__ attribute.
Return a new list of length len on success, or nil on failure.
Return a new tuple object of size len, or nil on failure.
go:linkname RunSimpleFile C.PyRun_SimpleFile.
go:linkname RunSimpleFileFlags C.PyRun_SimpleFileFlags.
go:linkname RunSimpleString C.PyRun_SimpleString.
go:linkname RunSimpleStringFlags C.PyRun_SimpleStringFlags.
go:linkname SetProgramName C.Py_SetProgramName.
go:linkname Str llgo.pystr.
go:linkname Uintptr C.PyLong_FromSize_t.
go:linkname Ulong C.PyLong_FromUnsignedLong.
go:linkname UlongLong C.PyLong_FromUnsignedLongLong.

# Constants

read code from string.
read code from filename.
No description provided by the author
No description provided by the author
read code from i/o.

# Structs

llgo:type C.
Object represents a Python object.

# Type aliases

No description provided by the author