Compare commits

..

1 Commits

13 changed files with 98 additions and 143 deletions

View File

@ -8,7 +8,6 @@ Copyright 2018 Datadog, Inc.
package python3 package python3
/* /*
#cgo pkg-config: python-3.9-embed
#include "Python.h" #include "Python.h"
#include "macro.h" #include "macro.h"
*/ */

View File

@ -8,7 +8,6 @@ Copyright 2018 Datadog, Inc.
package python3 package python3
/* /*
#cgo pkg-config: python-3.9-embed
#include "Python.h" #include "Python.h"
#include "macro.h" #include "macro.h"
*/ */

View File

@ -8,7 +8,6 @@ Copyright 2018 Datadog, Inc.
package python3 package python3
/* /*
#cgo pkg-config: python-3.9-embed
#include "Python.h" #include "Python.h"
#include "macro.h" #include "macro.h"
*/ */

View File

@ -137,6 +137,6 @@ func PyDict_Next(p *PyObject, ppos *int, pkey, pvalue **PyObject) bool {
} }
//PyDict_ClearFreeList : https://docs.python.org/3/c-api/dict.html#c.PyDict_ClearFreeList //PyDict_ClearFreeList : https://docs.python.org/3/c-api/dict.html#c.PyDict_ClearFreeList
//func PyDict_ClearFreeList() int { func PyDict_ClearFreeList() int {
// return int(C.PyDict_ClearFreeList()) return int(C.PyDict_ClearFreeList())
//} }

View File

@ -58,6 +58,6 @@ func PyFloat_GetMin() float64 {
} }
//PyFloat_ClearFreeList : https://docs.python.org/3/c-api/float.html#c.PyFloat_ClearFreeList //PyFloat_ClearFreeList : https://docs.python.org/3/c-api/float.html#c.PyFloat_ClearFreeList
//func PyFloat_ClearFreeList() int { func PyFloat_ClearFreeList() int {
// return int(C.PyFloat_ClearFreeList()) return int(C.PyFloat_ClearFreeList())
//} }

13
go.mod
View File

@ -1,13 +0,0 @@
module git.stein-ivar.net/steino/cpy3
go 1.20
require (
github.com/go-python/cpy3 v0.2.0
github.com/stretchr/testify v1.2.2
)
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
)

8
go.sum
View File

@ -1,8 +0,0 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-python/cpy3 v0.2.0 h1:IQ8v6KOTGSvejROZ8BPCfVW4rSMOKfpVwDi6sKYuu1w=
github.com/go-python/cpy3 v0.2.0/go.mod h1:W7F8SGWQv11501PYSj9d+NSv8U0/vWYa+FcMxBu4eqo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=

View File

@ -8,7 +8,7 @@ Copyright 2018 Datadog, Inc.
package python3 package python3
/* /*
#cgo pkg-config: python3 #cgo pkg-config: python-3.8-embed
#include "Python.h" #include "Python.h"
*/ */
import "C" import "C"

View File

@ -83,8 +83,6 @@ func PyList_AsTuple(list *PyObject) *PyObject {
} }
//PyList_ClearFreeList : https://docs.python.org/3/c-api/list.html#c.PyList_ClearFreeList //PyList_ClearFreeList : https://docs.python.org/3/c-api/list.html#c.PyList_ClearFreeList
/*
func PyList_ClearFreeList() int { func PyList_ClearFreeList() int {
return int(C.PyList_ClearFreeList()) return int(C.PyList_ClearFreeList())
} }
*/

1
sys.go
View File

@ -8,7 +8,6 @@ Copyright 2018 Datadog, Inc.
package python3 package python3
/* /*
#cgo pkg-config: python-3.9-embed
#include "Python.h" #include "Python.h"
*/ */
import "C" import "C"

View File

@ -19,11 +19,9 @@ type PyThreadState C.PyThreadState
type PyGILState C.PyGILState_STATE type PyGILState C.PyGILState_STATE
//PyEval_InitThreads : https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads //PyEval_InitThreads : https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads
/*
func PyEval_InitThreads() { func PyEval_InitThreads() {
C.PyEval_InitThreads() C.PyEval_InitThreads()
} }
*/
//PyEval_ThreadsInitialized : https://docs.python.org/3/c-api/init.html#c.PyEval_ThreadsInitialized //PyEval_ThreadsInitialized : https://docs.python.org/3/c-api/init.html#c.PyEval_ThreadsInitialized
func PyEval_ThreadsInitialized() bool { func PyEval_ThreadsInitialized() bool {
@ -50,13 +48,6 @@ func PyThreadState_Swap(tstate *PyThreadState) *PyThreadState {
return (*PyThreadState)(C.PyThreadState_Swap((*C.PyThreadState)(tstate))) return (*PyThreadState)(C.PyThreadState_Swap((*C.PyThreadState)(tstate)))
} }
// PyEval_ReInitThreads : https://docs.python.org/3/c-api/init.html#c.PyEval_ReInitThreads
/*
func PyEval_ReInitThreads() {
C.PyEval_ReInitThreads()
}
*/
//PyGILState_Ensure : https://docs.python.org/3/c-api/init.html#c.PyGILState_Ensure //PyGILState_Ensure : https://docs.python.org/3/c-api/init.html#c.PyGILState_Ensure
func PyGILState_Ensure() PyGILState { func PyGILState_Ensure() PyGILState {
return PyGILState(C.PyGILState_Ensure()) return PyGILState(C.PyGILState_Ensure())

View File

@ -6,15 +6,6 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
func TestThreadInitialization(t *testing.T) {
Py_Initialize()
PyEval_InitThreads()
assert.True(t, PyEval_ThreadsInitialized())
PyEval_ReInitThreads()
}
func TestGIL(t *testing.T) { func TestGIL(t *testing.T) {
Py_Initialize() Py_Initialize()
PyEval_InitThreads() PyEval_InitThreads()