File tree 2 files changed +4
-0
lines changed
2 files changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,8 @@ This avoids inadvertent calls to DecRef during recursions.")
167
167
; ; FIXME: Do we leak this into the python-object finalizers?
168
168
(defvar *pygc-enabled* t
169
169
" If NIL, expects PYGC to be called manually by the user." )
170
+ (defvar *pygc-threshold* 1000
171
+ " Number of references in *PYTHON-NEW-REFERENCES* after which PYGC manipulates reference counts." )
170
172
171
173
(defmacro enable-pygc ()
172
174
` (eval-when (:compile-toplevel :load-toplevel :execute )
@@ -194,6 +196,7 @@ This avoids inadvertent calls to DecRef during recursions.")
194
196
; ; :do (let ((ptr (make-pointer addr)))
195
197
; ; (format t "~%At ~A with refcnt ~A:~% ~A"
196
198
; ; ptr count (lispify ptr))))
199
+ (when (< (hash-table-count ht) *pygc-threshold* ) (return-from pygc))
197
200
(with-python-gil/no-errors
198
201
(with-hash-table-iterator (ht-iter ht)
199
202
(loop :do (multiple-value-bind (validp addr count ) (ht-iter)
Original file line number Diff line number Diff line change 4
4
# :%shared-library-from-ldflag)
5
5
(:export # :*internal-features*
6
6
7
+ # :*pygc-threshold*
7
8
# :with-pygc
8
9
# :enable-pygc
9
10
# :disable-pygc
You can’t perform that action at this time.
0 commit comments