From 1ed0ec674efe63912865183c0a1c66cc7d193fda Mon Sep 17 00:00:00 2001 From: Jonathan Dung Date: Sat, 28 Mar 2026 11:21:41 +0800 Subject: [PATCH] Load sysconfig only when needed --- Lib/ctypes/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py index 1c822759eca912..6db67afb597b1e 100644 --- a/Lib/ctypes/__init__.py +++ b/Lib/ctypes/__init__.py @@ -2,7 +2,6 @@ import os as _os import sys as _sys -import sysconfig as _sysconfig import types as _types from _ctypes import Union, Structure, Array @@ -550,7 +549,9 @@ def LoadLibrary(self, name): pythonapi = PyDLL("python dll", None, _sys.dllhandle) elif _sys.platform in ["android", "cygwin"]: # These are Unix-like platforms which use a dynamically-linked libpython. - pythonapi = PyDLL(_sysconfig.get_config_var("LDLIBRARY")) + import sysconfig # delay import + pythonapi = PyDLL(sysconfig.get_config_var("LDLIBRARY")) + del sysconfig else: pythonapi = PyDLL(None)