Skip to content

Commit 51f3943

Browse files
committed
clib: Search and load the GMT library only one time
1 parent bb82345 commit 51f3943

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: pygmt/clib/session.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@
8787
np.datetime64: "GMT_DATETIME",
8888
}
8989

90+
# load the GMT library outside the Session class so it's loaded once.
91+
_libgmt = load_libgmt()
92+
9093

9194
class Session:
9295
"""
@@ -308,7 +311,7 @@ def get_libgmt_func(self, name, argtypes=None, restype=None):
308311
<class 'ctypes.CDLL.__init__.<locals>._FuncPtr'>
309312
"""
310313
if not hasattr(self, "_libgmt"):
311-
self._libgmt = load_libgmt()
314+
self._libgmt = _libgmt
312315
function = getattr(self._libgmt, name)
313316
if argtypes is not None:
314317
function.argtypes = argtypes

0 commit comments

Comments
 (0)