diff options
| author | jvoisin | 2019-05-16 00:31:40 +0200 |
|---|---|---|
| committer | jvoisin | 2019-05-16 00:31:40 +0200 |
| commit | 35d550d229b219f5a02cb9194c3bd24329f975ed (patch) | |
| tree | 83b3617d7d0993ff0313d472adf8abb5a52fa1ac /libmat2 | |
| parent | aa52a5c91c1d7f0dc6691fdd972e343fc63f6fc2 (diff) | |
Use memoization get _*_path() functions
This shouldn't make a big difference in the CLI/extension
usage, but might improve the performances of long-running
instances, or people misusing the API.
Diffstat (limited to 'libmat2')
| -rw-r--r-- | libmat2/exiftool.py | 2 | ||||
| -rw-r--r-- | libmat2/video.py | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/libmat2/exiftool.py b/libmat2/exiftool.py index d18b1fb..2e83f13 100644 --- a/libmat2/exiftool.py +++ b/libmat2/exiftool.py | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | import functools | ||
| 1 | import json | 2 | import json |
| 2 | import logging | 3 | import logging |
| 3 | import os | 4 | import os |
| @@ -56,6 +57,7 @@ class ExiftoolParser(abstract.AbstractParser): | |||
| 56 | return False | 57 | return False |
| 57 | return True | 58 | return True |
| 58 | 59 | ||
| 60 | @functools.lru_cache() | ||
| 59 | def _get_exiftool_path() -> str: # pragma: no cover | 61 | def _get_exiftool_path() -> str: # pragma: no cover |
| 60 | possible_pathes = { | 62 | possible_pathes = { |
| 61 | '/usr/bin/exiftool', # debian/fedora | 63 | '/usr/bin/exiftool', # debian/fedora |
diff --git a/libmat2/video.py b/libmat2/video.py index 0060f78..1492ba1 100644 --- a/libmat2/video.py +++ b/libmat2/video.py | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | import functools | ||
| 1 | import os | 2 | import os |
| 2 | import logging | 3 | import logging |
| 3 | 4 | ||
| @@ -130,6 +131,7 @@ class MP4Parser(AbstractFFmpegParser): | |||
| 130 | } | 131 | } |
| 131 | 132 | ||
| 132 | 133 | ||
| 134 | @functools.lru_cache() | ||
| 133 | def _get_ffmpeg_path() -> str: # pragma: no cover | 135 | def _get_ffmpeg_path() -> str: # pragma: no cover |
| 134 | ffmpeg_path = '/usr/bin/ffmpeg' | 136 | ffmpeg_path = '/usr/bin/ffmpeg' |
| 135 | if os.path.isfile(ffmpeg_path): | 137 | if os.path.isfile(ffmpeg_path): |
