summaryrefslogtreecommitdiff
path: root/mesonbuild/backend
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2025-09-16 18:07:57 +0200
committerDylan Baker <dylan@pnwbakers.com>2025-09-22 08:34:09 -0700
commit0bb366b36131967579826d92f0733c301fd59565 (patch)
treed0d9264baa252e9a4ebaa00031590590d0d2e14c /mesonbuild/backend
parent8b3c6c9fb4b27c1a5635d2b498275ed2eb326a8f (diff)
downloadmeson-0bb366b36131967579826d92f0733c301fd59565.tar.gz
utils, backends: add and use unique_list
backends.py has an interesting idiom for keeping the unique elements of a list. This is much faster than OrderedSet: * dict.fromkeys() vs. OrderedSet.__init__(): 35% faster on Python 3.13, 50-60% faster on Python 3.10 * list(d) (d is a dict) vs. list(os) (os is an OrderedSet): up to 25% faster on Python 3.13, up to 15% faster on Python 3.10 though it tapers out after a few hundred elements. Add a function to mesonlib to encapsulate this idiom. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'mesonbuild/backend')
-rw-r--r--mesonbuild/backend/backends.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index 9a7700618..45b1374e8 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -29,7 +29,7 @@ from ..mesonlib import (
File, MachineChoice, MesonException, MesonBugException, OrderedSet,
ExecutableSerialisation, EnvironmentException,
classify_unity_sources, get_compiler_for_source,
- get_rsp_threshold,
+ get_rsp_threshold, unique_list
)
from ..options import OptionKey
@@ -471,11 +471,11 @@ class Backend:
def flatten_object_list(self, target: build.BuildTarget, proj_dir_to_build_root: str = ''
) -> T.Tuple[T.List[str], T.List[build.BuildTargetTypes]]:
obj_list, deps = self._flatten_object_list(target, target.get_objects(), proj_dir_to_build_root)
- return list(dict.fromkeys(obj_list)), deps
+ return unique_list(obj_list), deps
def determine_ext_objs(self, objects: build.ExtractedObjects) -> T.List[str]:
obj_list, _ = self._flatten_object_list(objects.target, [objects], '')
- return list(dict.fromkeys(obj_list))
+ return unique_list(obj_list)
def _flatten_object_list(self, target: build.BuildTarget,
objects: T.Sequence[T.Union[str, 'File', build.ExtractedObjects]],