Skip to content

Commit 304ee49

Browse files
committed
fixup! Update RefTrace's garbage collection
1 parent 5787dd0 commit 304ee49

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

python/segyio/trace.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,6 @@ class RefTrace(Trace):
412412
:attr:`Trace.ref`. This feature requires a context manager, to guarantee
413413
modifications are written back to disk.
414414
"""
415-
416-
# If there are no external references to the data (so only internal
417-
# references remain), the reference count is
418-
# - 2 (Python >= 3.14)
419-
# - 3 (Python < 3.14)
420-
_GARBAGE_THRESHOLD = 3 if sys.version_info < (3, 14) else 2
421-
422415
def __init__(self, *args):
423416
super(RefTrace, self).__init__(*args)
424417
self.refs = {}
@@ -442,6 +435,11 @@ def flush(self):
442435
be useful in certain contexts to provide stronger guarantees.
443436
"""
444437
garbage = []
438+
# If there are no external references to the data (so only internal
439+
# references remain), the reference count is
440+
# - 2 (Python >= 3.14)
441+
# - 3 (Python < 3.14)
442+
garbage_threshold = 3 if sys.version_info < (3, 14) else 2
445443

446444
for i, (x, signature) in self.refs.items():
447445
if sys.getrefcount(x) == self._GARBAGE_THRESHOLD:

0 commit comments

Comments
 (0)