From 80f1d791544c8dbb262dadf2cefe4e32a819928c Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Thu, 28 Dec 2023 21:59:58 +0800 Subject: [PATCH] clib: Search and load the GMT library only one time --- pygmt/clib/session.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pygmt/clib/session.py b/pygmt/clib/session.py index 1f338851a9a..b6a7f4c7bb6 100644 --- a/pygmt/clib/session.py +++ b/pygmt/clib/session.py @@ -87,6 +87,9 @@ np.datetime64: "GMT_DATETIME", } +# load the GMT library outside the Session class so it's loaded once. +_libgmt = load_libgmt() + class Session: """ @@ -308,7 +311,7 @@ def get_libgmt_func(self, name, argtypes=None, restype=None): ._FuncPtr'> """ if not hasattr(self, "_libgmt"): - self._libgmt = load_libgmt() + self._libgmt = _libgmt function = getattr(self._libgmt, name) if argtypes is not None: function.argtypes = argtypes