diff --git a/PySpice/Spice/NgSpice/Shared.py b/PySpice/Spice/NgSpice/Shared.py index 8a515dcd8..3af09718c 100644 --- a/PySpice/Spice/NgSpice/Shared.py +++ b/PySpice/Spice/NgSpice/Shared.py @@ -360,6 +360,8 @@ def __init__(self, ngspice_id=0, send_data=False): ############################################## + already_read_ffi = False + def _load_library(self): if ConfigInstall.OS.on_windows: @@ -369,9 +371,11 @@ def _load_library(self): if 'SPICE_LIB_DIR' not in os.environ: os.environ['SPICE_LIB_DIR'] = os.path.join(self.NGSPICE_PATH, 'share', 'ngspice') - api_path = os.path.join(os.path.dirname(__file__), 'api.h') - with open(api_path) as f: - ffi.cdef(f.read()) + if not NgSpiceShared.already_read_ffi: + NgSpiceShared.already_read_ffi = True + api_path = os.path.join(os.path.dirname(__file__), 'api.h') + with open(api_path) as f: + ffi.cdef(f.read()) if not self._ngspice_id: library_prefix = ''