summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/portage/util/_ctypes.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/pym/portage/util/_ctypes.py b/pym/portage/util/_ctypes.py
index f419b1926..4e5aa2a6b 100644
--- a/pym/portage/util/_ctypes.py
+++ b/pym/portage/util/_ctypes.py
@@ -31,15 +31,17 @@ def find_library(name):
return None
return filename
+_library_handles = {}
+
def LoadLibrary(name):
"""
Calls ctypes.cdll.LoadLibrary(name) if the ctypes module is available,
- and otherwise returns None. Results are not cached, since that can
- cause problems when libraries are updated (see bug #448858).
+ and otherwise returns None. Results are cached for future invocations.
"""
- handle = None
+ handle = _library_handles.get(name)
- if ctypes is not None:
+ if handle is None and ctypes is not None:
handle = ctypes.cdll.LoadLibrary(name)
+ _library_handles[name] = handle
return handle