Use __slots__ for fast attribute access
This commit is contained in:
parent
b6c8779772
commit
2b3f350071
@ -486,6 +486,8 @@ class HashableMap(MutableMapping):
|
|||||||
"""This is a hashable, comparable dictionary. Hash is performed on
|
"""This is a hashable, comparable dictionary. Hash is performed on
|
||||||
a tuple of the values in the dictionary."""
|
a tuple of the values in the dictionary."""
|
||||||
|
|
||||||
|
__slots__ = 'dict',
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.dict = {}
|
self.dict = {}
|
||||||
|
|
||||||
|
@ -243,6 +243,8 @@ def frontend_arch():
|
|||||||
"""Return the frontend architecture"""
|
"""Return the frontend architecture"""
|
||||||
return ArchSpec._return_arch("frontend", "frontend")
|
return ArchSpec._return_arch("frontend", "frontend")
|
||||||
|
|
||||||
|
__slots__ = '_platform', '_os', '_target'
|
||||||
|
|
||||||
def __init__(self, spec_or_platform_tuple=(None, None, None)):
|
def __init__(self, spec_or_platform_tuple=(None, None, None)):
|
||||||
"""Architecture specification a package should be built with.
|
"""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
|
versions that a package should be built with. CompilerSpecs have a
|
||||||
name and a version list."""
|
name and a version list."""
|
||||||
|
|
||||||
|
__slots__ = 'name', 'versions'
|
||||||
|
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
nargs = len(args)
|
nargs = len(args)
|
||||||
if nargs == 1:
|
if nargs == 1:
|
||||||
@ -677,6 +681,8 @@ class DependencySpec(object):
|
|||||||
- deptypes: list of strings, representing dependency relationships.
|
- deptypes: list of strings, representing dependency relationships.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
__slots__ = 'parent', 'spec', 'deptypes'
|
||||||
|
|
||||||
def __init__(self, parent, spec, deptypes):
|
def __init__(self, parent, spec, deptypes):
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.spec = spec
|
self.spec = spec
|
||||||
@ -717,6 +723,9 @@ def canonical(self):
|
|||||||
|
|
||||||
|
|
||||||
class FlagMap(lang.HashableMap):
|
class FlagMap(lang.HashableMap):
|
||||||
|
|
||||||
|
__slots__ = 'spec',
|
||||||
|
|
||||||
def __init__(self, spec):
|
def __init__(self, spec):
|
||||||
super(FlagMap, self).__init__()
|
super(FlagMap, self).__init__()
|
||||||
self.spec = spec
|
self.spec = spec
|
||||||
@ -801,6 +810,7 @@ class _EdgeMap(Mapping):
|
|||||||
|
|
||||||
Edges are stored in a dictionary and keyed by package name.
|
Edges are stored in a dictionary and keyed by package name.
|
||||||
"""
|
"""
|
||||||
|
__slots__ = 'edges', 'store_by_child'
|
||||||
|
|
||||||
def __init__(self, store_by=EdgeDirection.child):
|
def __init__(self, store_by=EdgeDirection.child):
|
||||||
# Sanitize input arguments
|
# Sanitize input arguments
|
||||||
|
Loading…
Reference in New Issue
Block a user