diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2022-06-07 18:07:13 +0200 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2022-08-02 10:52:52 -0700 |
commit | 2b3f350071c50f7d3850b72669ed536569a372a1 (patch) | |
tree | 8ffb6fa3f03984bbf7c7f455fbe2e5c552115971 | |
parent | b6c87797721fcdfd9b8ed87d993e16ca87138044 (diff) | |
download | spack-2b3f350071c50f7d3850b72669ed536569a372a1.tar.gz spack-2b3f350071c50f7d3850b72669ed536569a372a1.tar.bz2 spack-2b3f350071c50f7d3850b72669ed536569a372a1.tar.xz spack-2b3f350071c50f7d3850b72669ed536569a372a1.zip |
Use __slots__ for fast attribute access
-rw-r--r-- | lib/spack/llnl/util/lang.py | 2 | ||||
-rw-r--r-- | lib/spack/spack/spec.py | 10 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/spack/llnl/util/lang.py b/lib/spack/llnl/util/lang.py index 314566e97a..8ec7113782 100644 --- a/lib/spack/llnl/util/lang.py +++ b/lib/spack/llnl/util/lang.py @@ -486,6 +486,8 @@ class HashableMap(MutableMapping): """This is a hashable, comparable dictionary. Hash is performed on a tuple of the values in the dictionary.""" + __slots__ = 'dict', + def __init__(self): self.dict = {} diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index a325670289..fc8a884511 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -243,6 +243,8 @@ class ArchSpec(object): """Return the frontend architecture""" return ArchSpec._return_arch("frontend", "frontend") + __slots__ = '_platform', '_os', '_target' + def __init__(self, spec_or_platform_tuple=(None, None, None)): """Architecture specification a package should be built with. @@ -553,6 +555,8 @@ class CompilerSpec(object): versions that a package should be built with. CompilerSpecs have a name and a version list.""" + __slots__ = 'name', 'versions' + def __init__(self, *args): nargs = len(args) if nargs == 1: @@ -677,6 +681,8 @@ class DependencySpec(object): - deptypes: list of strings, representing dependency relationships. """ + __slots__ = 'parent', 'spec', 'deptypes' + def __init__(self, parent, spec, deptypes): self.parent = parent self.spec = spec @@ -717,6 +723,9 @@ _valid_compiler_flags = ["cflags", "cxxflags", "fflags", "ldflags", "ldlibs", "c class FlagMap(lang.HashableMap): + + __slots__ = 'spec', + def __init__(self, spec): super(FlagMap, self).__init__() self.spec = spec @@ -801,6 +810,7 @@ class _EdgeMap(Mapping): Edges are stored in a dictionary and keyed by package name. """ + __slots__ = 'edges', 'store_by_child' def __init__(self, store_by=EdgeDirection.child): # Sanitize input arguments |