fix: address review-bot findings on merged PRs (#593)

Squashed from PR #595. Closes #593.
This commit is contained in:
Vito Sansevero
2026-10-31 23:13:59 -07:00
parent 01a4f1d989
commit 85441aa637
10 changed files with 165 additions and 40 deletions
+5 -5
View File
@@ -16,8 +16,9 @@ import sys
import threading
_lock = threading.Lock()
_trim = None
_looked_up = False
# Not looked up yet; after the lookup, the function or None.
_NOT_LOOKED_UP = object()
_trim = _NOT_LOOKED_UP
def _glibc() -> bool:
@@ -33,10 +34,9 @@ def _glibc() -> bool:
def _malloc_trim():
"""glibc's ``malloc_trim``, looked up once; None where there is none."""
global _trim, _looked_up
global _trim
with _lock:
if not _looked_up:
_looked_up = True
if _trim is _NOT_LOOKED_UP:
_trim = _lookup()
return _trim