Skip to content

Commit b22933c

Browse files
committed
save current global data for delayed gc
1 parent 119982a commit b22933c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

object.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
// the Python Object's DecRef method during garbage collection.
1616
type pyObject struct {
1717
obj *C.PyObject
18+
g *globalData
1819
}
1920

2021
func (obj *pyObject) Obj() *PyObject {
@@ -54,9 +55,9 @@ func newObject(obj *PyObject) Object {
5455
C.PyErr_Print()
5556
panic("nil Python object")
5657
}
57-
o := &pyObject{obj: obj}
58+
o := &pyObject{obj: obj, g: getGlobalData()}
5859
runtime.SetFinalizer(o, func(o *pyObject) {
59-
getGlobalData().addDecRef(o.obj)
60+
o.g.addDecRef(o.obj)
6061
runtime.SetFinalizer(o, nil)
6162
})
6263
return Object{o}

0 commit comments

Comments
 (0)