GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - DataDog/go-python3: Go bindings to the CPython-3 API

This repository was archived by the owner on Aug 10, 2022. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

42 Commits
42 Commits

Folders and files

NameName
Last commit message
Last commit date
.circleci
.circleci
 
 
.github
.github
 
 
examples
examples
 
 
script
script
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
Gopkg.lock
Gopkg.lock
 
 
Gopkg.toml
Gopkg.toml
 
 
LICENSE
LICENSE
 
 
LICENSE-3rdparty.csv
LICENSE-3rdparty.csv
 
 
README.md
README.md
 
 
boolean.go
boolean.go
 
 
boolean_test.go
boolean_test.go
 
 
byte_array.go
byte_array.go
 
 
byte_array_test.go
byte_array_test.go
 
 
bytes.go
bytes.go
 
 
bytes_test.go
bytes_test.go
 
 
complex.go
complex.go
 
 
complex_test.go
complex_test.go
 
 
dict.go
dict.go
 
 
dict_test.go
dict_test.go
 
 
errors.go
errors.go
 
 
errors_nix.go
errors_nix.go
 
 
errors_test.go
errors_test.go
 
 
exceptions.go
exceptions.go
 
 
exceptions_test.go
exceptions_test.go
 
 
float.go
float.go
 
 
float_test.go
float_test.go
 
 
helper.go
helper.go
 
 
high_level_layer.go
high_level_layer.go
 
 
high_level_layer_test.go
high_level_layer_test.go
 
 
import.go
import.go
 
 
import_test.go
import_test.go
 
 
integer.go
integer.go
 
 
integer_test.go
integer_test.go
 
 
lifecycle.go
lifecycle.go
 
 
lifecycle_test.go
lifecycle_test.go
 
 
list.go
list.go
 
 
list_test.go
list_test.go
 
 
macro.c
macro.c
 
 
macro.h
macro.h
 
 
module.go
module.go
 
 
module_test.go
module_test.go
 
 
object.go
object.go
 
 
object_test.go
object_test.go
 
 
recursion.go
recursion.go
 
 
recursion_test.go
recursion_test.go
 
 
reflection.go
reflection.go
 
 
reflection_test.go
reflection_test.go
 
 
sys.go
sys.go
 
 
sys_test.go
sys_test.go
 
 
thread.go
thread.go
 
 
thread_test.go
thread_test.go
 
 
tuple.go
tuple.go
 
 
tuple_test.go
tuple_test.go
 
 
type.go
type.go
 
 
type_test.go
type_test.go
 
 
unicode.go
unicode.go
 
 
unicode_test.go
unicode_test.go
 
 
variadic.c
variadic.c
 
 
variadic.h
variadic.h
 
 
warning.go
warning.go
 
 
warning_test.go
warning_test.go
 
 

Repository files navigation

This repo will be archived on December 1st 2021. While still readable it will no longer be maintained. There's a community maintained successor of this project at https://github.com/go-python/cpy3 .

go-python3

Currently supports python-3.7 only.

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.

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

Deps

We will need pkg-config and a working python3.7 environment to build these bindings. Make sure you have Python libraries and header files installed as well (python3.7-dev on Debian or python3-devel on Centos for example)..

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.

Go get

Then simply go get github.com/DataDog/go-python3

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

About

Go bindings to the CPython-3 API

Topics

bindingsgogolangpythonpython3

Resources

Readme
MIT license

Contributing

Contributing
Activity
Custom properties

Stars

385 stars

Watchers

3 watching

Forks

142 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.