python3

package module
Version: v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2019 License: MIT Imports: 3 Imported by: 0

README

go-python3

Golang bindings for the C-API of CPython-3.

This package provides a go package named "python" under which most of the PyXYZ functions and macros of the public C-API of CPython have been exposed. Theoretically, you should be able use https://docs.python.org/3/c-api and know what to type in your go program.

Currently supports python-3.7+.

This project was inspired by https://github.com/sbinet/go-python. Go and take a look if we need something for python-2.7!

Install

Simply go get github.com/DataDog/go-python3

Build

We will need pkg-config and a working python3 environment to build these bindings. By default pkg-config will look at the python3 library so if you want to choose a specific version just symlink python-X.Y.pc to python3.pc or use the PKG_CONFIG_PATH environment variable.

API

Some functions mix go code and call to Python function. Those functions will return and int and error type. The int represent the Python result code and the error represent any issue from the Go layer.

Example:

func PyRun_AnyFile(filename string) open filename and then call CPython API function int PyRun_AnyFile(FILE *fp, const char *filename).

Therefore its signature is func PyRun_AnyFile(filename string) (int, error), the int represent the error code from the CPython PyRun_AnyFile function and error will be set if we failed to open filename.

If an error is raise before calling th CPython function int default to -1.

Take a look at some examples

Documentation

Index

Constants

View Source
const MaxVariadicLength = 20

MaxVariadicLength is the maximum number of arguments that can be passed to a variadic C function due to a cgo limitation

Variables

View Source
var (
	Py_False = togo(C.Py_False)
	Py_True  = togo(C.Py_True)
)

python boolean constants

View Source
var (
	PyExc_BaseException          = togo(C.PyExc_BaseException)
	PyExc_Exception              = togo(C.PyExc_Exception)
	PyExc_ArithmeticError        = togo(C.PyExc_ArithmeticError)
	PyExc_AssertionError         = togo(C.PyExc_AssertionError)
	PyExc_AttributeError         = togo(C.PyExc_AttributeError)
	PyExc_BlockingIOError        = togo(C.PyExc_BlockingIOError)
	PyExc_BrokenPipeError        = togo(C.PyExc_BrokenPipeError)
	PyExc_BufferError            = togo(C.PyExc_BufferError)
	PyExc_ChildProcessError      = togo(C.PyExc_ChildProcessError)
	PyExc_ConnectionAbortedError = togo(C.PyExc_ConnectionAbortedError)
	PyExc_ConnectionError        = togo(C.PyExc_ConnectionError)
	PyExc_ConnectionRefusedError = togo(C.PyExc_ConnectionRefusedError)
	PyExc_ConnectcionResetError  = togo(C.PyExc_ConnectionResetError)
	PyExc_EOFError               = togo(C.PyExc_EOFError)
	PyExc_FileExistsError        = togo(C.PyExc_FileExistsError)
	PyExc_FileNotFoundError      = togo(C.PyExc_FileNotFoundError)
	PyExc_FloatingPointError     = togo(C.PyExc_FloatingPointError)
	PyExc_GeneratorExit          = togo(C.PyExc_GeneratorExit)
	PyExc_ImportError            = togo(C.PyExc_ImportError)
	PyExc_IndentationError       = togo(C.PyExc_IndentationError)
	PyExc_IndexError             = togo(C.PyExc_IndexError)
	PyExc_InterruptedError       = togo(C.PyExc_InterruptedError)
	PyExc_IsADirectoryError      = togo(C.PyExc_IsADirectoryError)
	PyExc_KeyError               = togo(C.PyExc_KeyError)
	PyExc_KeyboardInterrupt      = togo(C.PyExc_KeyboardInterrupt)
	PyExc_LookupError            = togo(C.PyExc_LookupError)
	PyExc_MemoryError            = togo(C.PyExc_MemoryError)
	PyExc_ModuleNotFoundError    = togo(C.PyExc_ModuleNotFoundError)
	PyExc_NameError              = togo(C.PyExc_NameError)
	PyExc_NotADirectoryError     = togo(C.PyExc_NotADirectoryError)
	PyExc_NotImplementedError    = togo(C.PyExc_NotImplementedError)
	PyExc_OSError                = togo(C.PyExc_OSError)
	PyExc_OverflowError          = togo(C.PyExc_OverflowError)
	PyExc_PermissionError        = togo(C.PyExc_PermissionError)
	PyExc_ProcessLookupError     = togo(C.PyExc_ProcessLookupError)
	PyExc_RecursionError         = togo(C.PyExc_RecursionError)
	PyExc_ReferenceError         = togo(C.PyExc_ReferenceError)
	PyExc_RuntimeError           = togo(C.PyExc_RuntimeError)
	PyExc_StopAsyncIteration     = togo(C.PyExc_StopAsyncIteration)
	PyExc_StopIteration          = togo(C.PyExc_StopIteration)
	PyExc_SyntaxError            = togo(C.PyExc_SyntaxError)
	PyExc_SystemError            = togo(C.PyExc_SystemError)
	PyExc_SystemExit             = togo(C.PyExc_SystemExit)
	PyExc_TabError               = togo(C.PyExc_TabError)
	PyExc_TimeoutError           = togo(C.PyExc_TimeoutError)
	PyExc_TypeError              = togo(C.PyExc_TypeError)
	PyExc_UnboundLocalError      = togo(C.PyExc_UnboundLocalError)
	PyExc_UnicodeDecodeError     = togo(C.PyExc_UnicodeDecodeError)
	PyExc_UnicodeEncodeError     = togo(C.PyExc_UnicodeEncodeError)
	PyExc_UnicodeError           = togo(C.PyExc_UnicodeError)
	PyExc_UnicodeTranslateError  = togo(C.PyExc_UnicodeTranslateError)
	PyExc_ValueError             = togo(C.PyExc_ValueError)
	PyExc_ZeroDivisionError      = togo(C.PyExc_ZeroDivisionError)
)

All standard Python exceptions are available as global variables whose names are PyExc_ followed by the Python exception name. These have the type PyObject*; they are all class objects.

View Source
var (
	Py_LT = int(C.Py_LT)
	Py_LE = int(C.Py_LE)
	Py_EQ = int(C.Py_EQ)
	Py_NE = int(C.Py_NE)
	Py_GT = int(C.Py_GT)
	Py_GE = int(C.Py_GE)
)

Constants used for comparison in PyObject_RichCompareBool

View Source
var (
	PyExc_Warning                   = togo(C.PyExc_Warning)
	PyExc_BytesWarning              = togo(C.PyExc_BytesWarning)
	PyExc_DeprecationWarning        = togo(C.PyExc_DeprecationWarning)
	PyExc_FutureWarning             = togo(C.PyExc_FutureWarning)
	PyExc_ImportWarning             = togo(C.PyExc_ImportWarning)
	PyExc_PendingDeprecationWarning = togo(C.PyExc_PendingDeprecationWarning)
	PyExc_ResourceWarning           = togo(C.PyExc_ResourceWarning)
	PyExc_RuntimeWarning            = togo(C.PyExc_RuntimeWarning)
	PyExc_SyntaxWarning             = togo(C.PyExc_SyntaxWarning)
	PyExc_UnicodeWarning            = togo(C.PyExc_UnicodeWarning)
	PyExc_UserWarning               = togo(C.PyExc_UserWarning)
)

All standard Python warning categories are available as global variables whose names are PyExc_ followed by the Python exception name. These have the type PyObject*; they are all class objects.

View Source
var Bool = togo((*C.PyObject)(unsafe.Pointer(&C.PyBool_Type)))

Bool : https://docs.python.org/3/c-api/bool.html#c.PyBool_Type

View Source
var ByteArray = togo((*C.PyObject)(unsafe.Pointer(&C.PyByteArray_Type)))

ByteArray : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_Type

View Source
var Bytes = togo((*C.PyObject)(unsafe.Pointer(&C.PyBytes_Type)))

Bytes : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_Type

View Source
var Complex = togo((*C.PyObject)(unsafe.Pointer(&C.PyComplex_Type)))

Complex : https://docs.python.org/3/c-api/complex.html#c.PyComplex_Type

View Source
var Dict = togo((*C.PyObject)(unsafe.Pointer(&C.PyDict_Type)))

Dict : https://docs.python.org/3/c-api/dict.html#c.PyDict_Type

View Source
var Float = togo((*C.PyObject)(unsafe.Pointer(&C.PyFloat_Type)))

Float : https://docs.python.org/3/c-api/float.html#c.PyFloat_Type

View Source
var List = togo((*C.PyObject)(unsafe.Pointer(&C.PyList_Type)))

List : https://docs.python.org/3/c-api/list.html#c.PyList_Type

View Source
var Long = togo((*C.PyObject)(unsafe.Pointer(&C.PyLong_Type)))

Long : https://docs.python.org/3/c-api/long.html#c.PyLong_Type

View Source
var Module = togo((*C.PyObject)(unsafe.Pointer(&C.PyModule_Type)))

Module : https://docs.python.org/3/c-api/module.html#c.PyModule_Type

View Source
var Py_None = togo(C.Py_None)

None : https://docs.python.org/3/c-api/none.html#c.Py_None

View Source
var Tuple = togo((*C.PyObject)(unsafe.Pointer(&C.PyTuple_Type)))

Tuple : https://docs.python.org/3/c-api/tuple.html#c.PyTuple_Type

View Source
var Type = togo((*C.PyObject)(unsafe.Pointer(&C.PyType_Type)))

Type : https://docs.python.org/3/c-api/type.html#c.PyType_Type

View Source
var Unicode = togo((*C.PyObject)(unsafe.Pointer(&C.PyUnicode_Type)))

Unicode : https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_Type

Functions

func PyByteArray_Resize

func PyByteArray_Resize(bytearray *PyObject, len int)

PyByteArray_Resize : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_Resize

func PyDict_ClearFreeList

func PyDict_ClearFreeList() int

PyDict_ClearFreeList : https://docs.python.org/3/c-api/dict.html#c.PyDict_ClearFreeList

func PyDict_Contains

func PyDict_Contains(p, key *PyObject) int

PyDict_Contains : https://docs.python.org/3/c-api/dict.html#c.PyDict_Contains

func PyDict_DelItem

func PyDict_DelItem(p, key *PyObject) int

PyDict_DelItem : https://docs.python.org/3/c-api/dict.html#c.PyDict_DelItem

func PyDict_DelItemString

func PyDict_DelItemString(p *PyObject, key string) int

PyDict_DelItemString : https://docs.python.org/3/c-api/dict.html#c.PyDict_DelItemString

func PyDict_Next

func PyDict_Next(p *PyObject, ppos *int, pkey, pvalue **PyObject) bool

PyDict_Next : https://docs.python.org/3/c-api/dict.html#c.PyDict_Next

func PyDict_SetItem

func PyDict_SetItem(p, key, val *PyObject) int

PyDict_SetItem : https://docs.python.org/3/c-api/dict.html#c.PyDict_SetItem

func PyDict_SetItemString

func PyDict_SetItemString(p *PyObject, key string, val *PyObject) int

PyDict_SetItemString : https://docs.python.org/3/c-api/dict.html#c.PyDict_SetItemString

func PyErr_GivenExceptionMatches

func PyErr_GivenExceptionMatches(given, exc *PyObject) bool

PyErr_GivenExceptionMatches : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_GivenExceptionMatches

func PyErr_NormalizeException

func PyErr_NormalizeException(exc, val, tb *PyObject) (*PyObject, *PyObject, *PyObject)

PyErr_NormalizeException : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_NormalizeException

func PyErr_PrintEx

func PyErr_PrintEx(setSysLastVars bool)

PyErr_PrintEx : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_PrintEx

func PyErr_Restore

func PyErr_Restore(pyType *PyObject, value *PyObject, traceback *PyObject)

PyErr_Restore : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_Restore

func PyErr_SetExcInfo

func PyErr_SetExcInfo(pyType *PyObject, value *PyObject, traceback *PyObject)

PyErr_SetExcInfo : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_SetExcInfo

func PyErr_SetObject

func PyErr_SetObject(pyType, value *PyObject)

PyErr_SetObject : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_SetObject

func PyErr_SetString

func PyErr_SetString(pyType *PyObject, message string)

PyErr_SetString : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_SetString

func PyErr_SyntaxLocation

func PyErr_SyntaxLocation(filename string, lineno int)

PyErr_SyntaxLocation : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_SyntaxLocation

func PyErr_SyntaxLocationEx

func PyErr_SyntaxLocationEx(filename string, lineno, col_offset int)

PyErr_SyntaxLocationEx : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_SyntaxLocationEx

func PyErr_SyntaxLocationObject

func PyErr_SyntaxLocationObject(filename *PyObject, lineno, col_offset int)

PyErr_SyntaxLocationObject : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_SyntaxLocationObject

func PyErr_WarnEx

func PyErr_WarnEx(category *PyObject, message string, stack_level int) int

PyErr_WarnEx : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_WarnEx

func PyErr_WarnExplicit

func PyErr_WarnExplicit(category *PyObject, message string, filename string, lineno int, module string, registry *PyObject) int

PyErr_WarnExplicit : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_WarnExplicit

func PyErr_WarnExplicitObject

func PyErr_WarnExplicitObject(category *PyObject, message *PyObject, filename *PyObject, lineno int, module *PyObject, registry *PyObject) int

PyErr_WarnExplicitObject : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_WarnExplicitObject

func PyEval_InitThreads

func PyEval_InitThreads()

PyEval_InitThreads : https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads

func PyEval_ReInitThreads

func PyEval_ReInitThreads()

PyEval_ReInitThreads : https://docs.python.org/3/c-api/init.html#c.PyEval_ReInitThreads

func PyEval_RestoreThread

func PyEval_RestoreThread(tstate *PyThreadState)

PyEval_RestoreThread : https://docs.python.org/3/c-api/init.html#c.PyEval_RestoreThread

func PyEval_ThreadsInitialized

func PyEval_ThreadsInitialized() bool

PyEval_ThreadsInitialized : https://docs.python.org/3/c-api/init.html#c.PyEval_ThreadsInitialized

func PyException_SetCause

func PyException_SetCause(ex, cause *PyObject)

PyException_SetCause : https://docs.python.org/3/c-api/exceptions.html#c.PyException_SetCause

func PyException_SetContext

func PyException_SetContext(ex, ctx *PyObject)

PyException_SetContext : https://docs.python.org/3/c-api/exceptions.html#c.PyException_SetContext

func PyException_SetTraceback

func PyException_SetTraceback(ex, tb *PyObject) int

PyException_SetTraceback : https://docs.python.org/3/c-api/exceptions.html#c.PyException_SetTraceback

func PyFloat_ClearFreeList

func PyFloat_ClearFreeList() int

PyFloat_ClearFreeList : https://docs.python.org/3/c-api/float.html#c.PyFloat_ClearFreeList

func PyGILState_Release

func PyGILState_Release(state PyGILState)

PyGILState_Release : https://docs.python.org/3/c-api/init.html#c.PyGILState_Release

func PyImport_GetMagicNumber

func PyImport_GetMagicNumber() int

PyImport_GetMagicNumber : https://docs.python.org/3/c-api/import.html#c.PyImport_GetMagicNumber

func PyImport_ImportFrozenModule

func PyImport_ImportFrozenModule(name string) int

PyImport_ImportFrozenModule : https://docs.python.org/3/c-api/import.html#c.PyImport_ImportFrozenModule

func PyImport_ImportFrozenModuleObject

func PyImport_ImportFrozenModuleObject(name *PyObject) int

PyImport_ImportFrozenModuleObject : https://docs.python.org/3/c-api/import.html#c.PyImport_ImportFrozenModuleObject

func PyList_Append

func PyList_Append(p, item *PyObject) int

PyList_Append : https://docs.python.org/3/c-api/list.html#c.PyList_Append

func PyList_ClearFreeList

func PyList_ClearFreeList() int

PyList_ClearFreeList : https://docs.python.org/3/c-api/list.html#c.PyList_ClearFreeList

func PyList_Insert

func PyList_Insert(p *PyObject, index int, item *PyObject) int

PyList_Insert : https://docs.python.org/3/c-api/list.html#c.PyList_Insert

func PyList_SetSlice

func PyList_SetSlice(p *PyObject, low, high int, itemlist *PyObject) int

PyList_SetSlice : https://docs.python.org/3/c-api/list.html#c.PyList_SetSlice

func PyLong_AsLongAndOverflow

func PyLong_AsLongAndOverflow(obj *PyObject) (int, int)

PyLong_AsLongAndOverflow : https://docs.python.org/3/c-api/long.html#c.PyLong_AsLongAndOverflow

func PyLong_AsLongLongAndOverflow

func PyLong_AsLongLongAndOverflow(obj *PyObject) (int64, int)

PyLong_AsLongLongAndOverflow : https://docs.python.org/3/c-api/long.html#c.PyLong_AsLongLongAndOverflow

func PyLong_AsUnsignedLong

func PyLong_AsUnsignedLong(obj *PyObject) uint

PyLong_AsUnsignedLong : https://docs.python.org/3/c-api/long.html#c.PyLong_AsUnsignedLong

func PyLong_AsUnsignedLongLong

func PyLong_AsUnsignedLongLong(obj *PyObject) uint64

PyLong_AsUnsignedLongLong : https://docs.python.org/3/c-api/long.html#c.PyLong_AsUnsignedLongLong

func PyLong_AsUnsignedLongLongMask

func PyLong_AsUnsignedLongLongMask(obj *PyObject) uint64

PyLong_AsUnsignedLongLongMask : https://docs.python.org/3/c-api/long.html#c.PyLong_AsUnsignedLongLongMask

func PyLong_AsUnsignedLongMask

func PyLong_AsUnsignedLongMask(obj *PyObject) uint

PyLong_AsUnsignedLongMask : https://docs.python.org/3/c-api/long.html#c.PyLong_AsUnsignedLongMask

func PyRun_AnyFile

func PyRun_AnyFile(filename string) (int, error)

PyRun_AnyFile : https://docs.python.org/3/c-api/veryhigh.html?highlight=pycompilerflags#c.PyRun_AnyFile "error" will be set if we fail to open "filename".

func PySys_ResetWarnOptions

func PySys_ResetWarnOptions()

PySys_ResetWarnOptions : https://docs.python.org/3/c-api/sys.html#c.PySys_ResetWarnOptions

func PySys_SetArgvEx

func PySys_SetArgvEx(args []string, updatepath bool) error

PySys_SetArgvEx : https://docs.python.org/3/c-api/init.html#c.PySys_SetArgvEx

func PyUnicode_CopyCharacters

func PyUnicode_CopyCharacters(to, from *PyObject, to_start, from_start, how_many int) int

PyUnicode_CopyCharacters : https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_CopyCharacters

func PyUnicode_Fill

func PyUnicode_Fill(unicode *PyObject, start, length int, fill_char rune) int

PyUnicode_Fill : https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_Fill

func PyUnicode_GetLength

func PyUnicode_GetLength(unicode *PyObject) int

PyUnicode_GetLength : https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_GetLength

func PyUnicode_ReadChar

func PyUnicode_ReadChar(unicode *PyObject, index int) rune

PyUnicode_ReadChar : https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_ReadChar

func PyUnicode_WriteChar

func PyUnicode_WriteChar(unicode *PyObject, index int, character rune) int

PyUnicode_WriteChar : https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_WriteChar

func Py_EnterRecursiveCall

func Py_EnterRecursiveCall(where string) int

Py_EnterRecursiveCall : https://docs.python.org/3/c-api/exceptions.html#c.Py_EnterRecursiveCall

func Py_GetProgramFullPath

func Py_GetProgramFullPath() (string, error)

Py_GetProgramFullPath : https://docs.python.org/3/c-api/init.html#c.Py_GetProgramFullPath

func Py_InitializeEx

func Py_InitializeEx(initsigs bool)

Py_InitializeEx : https://docs.python.org/3/c-api/init.html#c.Py_InitializeEx

func Py_Main

func Py_Main(args []string) (int, error)

Py_Main : https://docs.python.org/3/c-api/veryhigh.html?highlight=pycompilerflags#c.Py_Main "error" will be set if we fail to call "Py_DecodeLocale" on every "args".

func Py_SetStandardStreamEncoding

func Py_SetStandardStreamEncoding(encoding, errors string) int

Py_SetStandardStreamEncoding : https://docs.python.org/3/c-api/init.html#c.Py_SetStandardStreamEncoding

Types

type PyGILState

type PyGILState C.PyGILState_STATE

PyGILState is an opaque “handle” to the thread state when PyGILState_Ensure() was called, and must be passed to PyGILState_Release() to ensure Python is left in the same state

type PyObject

type PyObject C.PyObject

PyObject : https://docs.python.org/3/c-api/structures.html?highlight=pyobject#c.PyObject

func PyByteArray_FromStringAndSize

func PyByteArray_FromStringAndSize(str string) *PyObject

PyByteArray_FromStringAndSize : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_FromStringAndSize

func PyBytes_Concat

func PyBytes_Concat(bytes, newpart *PyObject) *PyObject

PyBytes_Concat : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_Concat

func PyBytes_ConcatAndDel

func PyBytes_ConcatAndDel(bytes, newpart *PyObject) *PyObject

PyBytes_ConcatAndDel : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_ConcatAndDel

func PyComplex_FromDoubles

func PyComplex_FromDoubles(real, imag float64) *PyObject

PyComplex_FromDoubles : https://docs.python.org/3/c-api/complex.html#c.PyComplex_FromDoubles

func PyDict_GetItemWithError

func PyDict_GetItemWithError(p, key *PyObject) *PyObject

PyDict_GetItemWithError : https://docs.python.org/3/c-api/dict.html#c.PyDict_GetItemWithError

func PyDict_SetDefault

func PyDict_SetDefault(p, key, pyDefault *PyObject) *PyObject

PyDict_SetDefault : https://docs.python.org/3/c-api/dict.html#c.PyDict_SetDefault

func PyErr_NewException

func PyErr_NewException(name string, base, dict *PyObject) *PyObject

PyErr_NewException : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_NewException

func PyErr_NewExceptionWithDoc

func PyErr_NewExceptionWithDoc(name, doc string, base, dict *PyObject) *PyObject

PyErr_NewExceptionWithDoc : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_NewExceptionWithDoc

func PyErr_SetImportError

func PyErr_SetImportError(msg, name, path *PyObject) *PyObject

PyErr_SetImportError : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_SetImportError

func PyErr_SetImportErrorSubclass

func PyErr_SetImportErrorSubclass(msg, name, path, subclass *PyObject) *PyObject

PyErr_SetImportErrorSubclass : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_SetImportErrorSubclass

func PyImport_AddModuleObject

func PyImport_AddModuleObject(name *PyObject) *PyObject

PyImport_AddModuleObject : https://docs.python.org/3/c-api/import.html#c.PyImport_AddModuleObject

func PyImport_ExecCodeModule

func PyImport_ExecCodeModule(name string, co *PyObject) *PyObject

PyImport_ExecCodeModule : https://docs.python.org/3/c-api/import.html#c.PyImport_ExecCodeModule

func PyImport_ExecCodeModuleEx

func PyImport_ExecCodeModuleEx(name string, co *PyObject, pathname string) *PyObject

PyImport_ExecCodeModuleEx : https://docs.python.org/3/c-api/import.html#c.PyImport_ExecCodeModuleEx

func PyImport_ExecCodeModuleObject

func PyImport_ExecCodeModuleObject(name, co, pathname, cpathname *PyObject) *PyObject

PyImport_ExecCodeModuleObject : https://docs.python.org/3/c-api/import.html#c.PyImport_ExecCodeModuleObject

func PyImport_ExecCodeModuleWithPathnames

func PyImport_ExecCodeModuleWithPathnames(name string, co *PyObject, pathname string, cpathname string) *PyObject

PyImport_ExecCodeModuleWithPathnames : https://docs.python.org/3/c-api/import.html#c.PyImport_ExecCodeModuleWithPathnames

func PyImport_ImportModuleEx

func PyImport_ImportModuleEx(name string, globals, locals, fromlist *PyObject) *PyObject

PyImport_ImportModuleEx : https://docs.python.org/3/c-api/import.html#c.PyImport_ImportModuleEx

func PyImport_ImportModuleLevel

func PyImport_ImportModuleLevel(name string, globals, locals, fromlist *PyObject, level int) *PyObject

PyImport_ImportModuleLevel : https://docs.python.org/3/c-api/import.html#c.PyImport_ImportModuleLevel

func PyImport_ImportModuleLevelObject

func PyImport_ImportModuleLevelObject(name, globals, locals, fromlist *PyObject, level int) *PyObject

PyImport_ImportModuleLevelObject : https://docs.python.org/3/c-api/import.html#c.PyImport_ImportModuleLevelObject

func PyList_GetSlice

func PyList_GetSlice(p *PyObject, low, high int) *PyObject

PyList_GetSlice : https://docs.python.org/3/c-api/list.html#c.PyList_GetSlice

func PyLong_FromGoFloat64

func PyLong_FromGoFloat64(v float64) *PyObject

PyLong_FromGoFloat64 ensures the go integer type does not overflow

func PyLong_FromGoInt

func PyLong_FromGoInt(v int) *PyObject

PyLong_FromGoInt ensures the go integer type does not overflow

func PyLong_FromGoInt64

func PyLong_FromGoInt64(v int64) *PyObject

PyLong_FromGoInt64 ensures the go integer type does not overflow

func PyLong_FromGoUint

func PyLong_FromGoUint(v uint) *PyObject

PyLong_FromGoUint ensures the go integer type does not overflow

func PyLong_FromGoUint64

func PyLong_FromGoUint64(v uint64) *PyObject

PyLong_FromGoUint64 ensures the go integer type does not overflow

func PyLong_FromString

func PyLong_FromString(str string, base int) *PyObject

PyLong_FromString : https://docs.python.org/3/c-api/long.html#c.PyLong_FromString

func PyLong_FromUnicodeObject

func PyLong_FromUnicodeObject(u *PyObject, base int) *PyObject

PyLong_FromUnicodeObject : https://docs.python.org/3/c-api/long.html#c.PyLong_FromUnicodeObject

func PyLong_FromUnsignedLong

func PyLong_FromUnsignedLong(v uint) *PyObject

PyLong_FromUnsignedLong : https://docs.python.org/3/c-api/long.html#c.PyLong_FromUnsignedLong

func PyLong_FromUnsignedLongLong

func PyLong_FromUnsignedLongLong(v uint64) *PyObject

PyLong_FromUnsignedLongLong : https://docs.python.org/3/c-api/long.html#c.PyLong_FromUnsignedLongLong

func PyModule_GetFilenameObject

func PyModule_GetFilenameObject(module *PyObject) *PyObject

PyModule_GetFilenameObject : https://docs.python.org/3/c-api/module.html#c.PyModule_GetFilenameObject

func PyModule_GetNameObject

func PyModule_GetNameObject(module *PyObject) *PyObject

PyModule_GetNameObject : https://docs.python.org/3/c-api/module.html#c.PyModule_GetNameObject

func PyTuple_GetSlice

func PyTuple_GetSlice(p *PyObject, low, high int) *PyObject

PyTuple_GetSlice : https://docs.python.org/3/c-api/tuple.html#c.PyTuple_GetSlice

func PyUnicode_FromEncodedObject

func PyUnicode_FromEncodedObject(obj *PyObject, encoding, errors string) *PyObject

PyUnicode_FromEncodedObject : https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_FromEncodedObject

func PyUnicode_New

func PyUnicode_New(size int, maxchar rune) *PyObject

PyUnicode_New : https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_New

func PyUnicode_Substring

func PyUnicode_Substring(unicode *PyObject, start, end int) *PyObject

PyUnicode_Substring : https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_Substring

func (*PyObject) ASCII

func (pyObject *PyObject) ASCII() *PyObject

ASCII : https://docs.python.org/3/c-api/object.html#c.PyObject_ASCII

func (*PyObject) Bytes

func (pyObject *PyObject) Bytes() *PyObject

Bytes : https://docs.python.org/3/c-api/object.html#c.PyObject_Bytes

func (*PyObject) Call

func (pyObject *PyObject) Call(args *PyObject, kwargs *PyObject) *PyObject

Call : https://docs.python.org/3/c-api/object.html#c.PyObject_Call

func (*PyObject) CallFunctionObjArgs

func (pyObject *PyObject) CallFunctionObjArgs(args ...*PyObject) *PyObject

CallFunctionObjArgs : https://docs.python.org/3/c-api/object.html#c.PyObject_CallFunctionObjArgs

func (*PyObject) CallMethodArgs

func (pyObject *PyObject) CallMethodArgs(name string, args ...*PyObject) *PyObject

CallMethodArgs : same as CallMethodObjArgs but with name as go string

func (*PyObject) CallMethodObjArgs

func (pyObject *PyObject) CallMethodObjArgs(name *PyObject, args ...*PyObject) *PyObject

CallMethodObjArgs : https://docs.python.org/3/c-api/object.html#c.PyObject_CallMethodObjArgs

func (*PyObject) CallObject

func (pyObject *PyObject) CallObject(args *PyObject) *PyObject

CallObject : https://docs.python.org/3/c-api/object.html#c.PyObject_CallObject

func (*PyObject) DecRef

func (pyObject *PyObject) DecRef()

DecRef : https://docs.python.org/3/c-api/refcounting.html#c.Py_DECREF

func (*PyObject) DelAttr

func (pyObject *PyObject) DelAttr(attr_name *PyObject) int

DelAttr : https://docs.python.org/3/c-api/object.html#c.PyObject_DelAttr

func (*PyObject) DelAttrString

func (pyObject *PyObject) DelAttrString(attr_name string) int

DelAttrString : https://docs.python.org/3/c-api/object.html#c.PyObject_DelAttrString

func (*PyObject) DelItem

func (pyObject *PyObject) DelItem(key *PyObject) int

DelItem : https://docs.python.org/3/c-api/object.html#c.PyObject_DelItem

func (*PyObject) Dir

func (pyObject *PyObject) Dir() *PyObject

Dir : https://docs.python.org/3/c-api/object.html#c.PyObject_Dir

func (*PyObject) GetAttr

func (pyObject *PyObject) GetAttr(attr_name *PyObject) *PyObject

GetAttr : https://docs.python.org/3/c-api/object.html#c.PyObject_GetAttr

func (*PyObject) GetAttrString

func (pyObject *PyObject) GetAttrString(attr_name string) *PyObject

GetAttrString : https://docs.python.org/3/c-api/object.html#c.PyObject_GetAttrString

func (*PyObject) GetItem

func (pyObject *PyObject) GetItem(key *PyObject) *PyObject

GetItem : https://docs.python.org/3/c-api/object.html#c.PyObject_GetItem

func (*PyObject) GetIter

func (pyObject *PyObject) GetIter() *PyObject

GetIter : https://docs.python.org/3/c-api/object.html#c.PyObject_GetIter

func (*PyObject) HasAttr

func (pyObject *PyObject) HasAttr(attr_name *PyObject) bool

HasAttr : https://docs.python.org/3/c-api/object.html#c.PyObject_HasAttr

func (*PyObject) HasAttrString

func (pyObject *PyObject) HasAttrString(attr_name string) bool

HasAttrString : https://docs.python.org/3/c-api/object.html#c.PyObject_HasAttrString

func (*PyObject) Hash

func (pyObject *PyObject) Hash() int

Hash : https://docs.python.org/3/c-api/object.html#c.PyObject_Hash

func (*PyObject) HashNotImplemented

func (pyObject *PyObject) HashNotImplemented() int

HashNotImplemented : https://docs.python.org/3/c-api/object.html#c.PyObject_HashNotImplemented

func (*PyObject) IncRef

func (pyObject *PyObject) IncRef()

IncRef : https://docs.python.org/3/c-api/refcounting.html#c.Py_INCREF

func (*PyObject) IsInstance

func (pyObject *PyObject) IsInstance(cls *PyObject) int

IsInstance : https://docs.python.org/3/c-api/object.html#c.PyObject_IsInstance

func (*PyObject) IsSubclass

func (pyObject *PyObject) IsSubclass(cls *PyObject) int

IsSubclass : https://docs.python.org/3/c-api/object.html#c.PyObject_IsSubclass

func (*PyObject) IsTrue

func (pyObject *PyObject) IsTrue() int

IsTrue : https://docs.python.org/3/c-api/object.html#c.PyObject_IsTrue

func (*PyObject) Length

func (pyObject *PyObject) Length() int

Length : https://docs.python.org/3/c-api/object.html#c.PyObject_Length

func (*PyObject) LengthHint

func (pyObject *PyObject) LengthHint(pyDefault int) int

LengthHint : https://docs.python.org/3/c-api/object.html#c.PyObject_LengthHint

func (*PyObject) Not

func (pyObject *PyObject) Not() int

Not : https://docs.python.org/3/c-api/object.html#c.PyObject_Not

func (*PyObject) Repr

func (pyObject *PyObject) Repr() *PyObject

Repr : https://docs.python.org/3/c-api/object.html#c.PyObject_Repr

func (*PyObject) ReprEnter

func (pyObject *PyObject) ReprEnter() int

ReprEnter : https://docs.python.org/3/c-api/exceptions.html#c.Py_ReprEnter

func (*PyObject) ReprLeave

func (pyObject *PyObject) ReprLeave()

ReprLeave : https://docs.python.org/3/c-api/exceptions.html#c.Py_ReprLeave

func (*PyObject) RichCompare

func (pyObject *PyObject) RichCompare(o *PyObject, opid int) *PyObject

RichCompare : https://docs.python.org/3/c-api/object.html#c.PyObject_RichCompare

func (*PyObject) RichCompareBool

func (pyObject *PyObject) RichCompareBool(o *PyObject, opid int) int

RichCompareBool : https://docs.python.org/3/c-api/object.html#c.PyObject_RichCompareBool

func (*PyObject) SetAttr

func (pyObject *PyObject) SetAttr(attr_name *PyObject, v *PyObject) int

SetAttr : https://docs.python.org/3/c-api/object.html#c.PyObject_SetAttr

func (*PyObject) SetAttrString

func (pyObject *PyObject) SetAttrString(attr_name string, v *PyObject) int

SetAttrString : https://docs.python.org/3/c-api/object.html#c.PyObject_SetAttrString

func (*PyObject) SetItem

func (pyObject *PyObject) SetItem(key, v *PyObject) int

SetItem : https://docs.python.org/3/c-api/object.html#c.PyObject_SetItem

func (*PyObject) Str

func (pyObject *PyObject) Str() *PyObject

Str : https://docs.python.org/3/c-api/object.html#c.PyObject_Str

func (*PyObject) Type

func (pyObject *PyObject) Type() *PyObject

Type : https://docs.python.org/3/c-api/object.html#c.PyObject_Type

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL