Skip to content

Commit

Permalink
clib: Search and load the GMT library only one time
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman committed Dec 28, 2023
1 parent bb82345 commit 80f1d79
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pygmt/clib/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down Expand Up @@ -308,7 +311,7 @@ def get_libgmt_func(self, name, argtypes=None, restype=None):
<class 'ctypes.CDLL.__init__.<locals>._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
Expand Down

0 comments on commit 80f1d79

Please sign in to comment.