Skip to content

Commit e7cc71e

Browse files
committed
chore: add missing __slots__ for various mappings.
These always should've been there, it's just older code from before the slotting work. Being the underlying classes *are* slotted, slot these. Note: this can result in exposing bugs in code deriving from these classes, which was setting it's own __slots__. Effectively the __dict__ just got removed, so their class *will* do what they intended- be slotted. If there code didn't account for all needed slots, it'll break. Nothing I've audited is at risk, and their code would be buggy anyways, so this change is safe. Signed-off-by: Brian Harring <ferringb@gmail.com>
1 parent dd47ac1 commit e7cc71e

File tree

8 files changed

+15
-2
lines changed

8 files changed

+15
-2
lines changed

src/pkgcore/binpkg/remote.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class CacheEntry(StackedDict):
3636
returns None instead. This is likely to be changed.
3737
"""
3838

39+
__slots__ = ()
40+
3941
def pop(self, key, default=None):
4042
try:
4143
return self[key]

src/pkgcore/binpkg/repository.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ def __contains__(self, key):
184184

185185

186186
class StackedCache(StackedDict):
187+
__slots__ = ()
187188
__externally_mutable__ = True
188189

189190
def __delitem__(self, key):

src/pkgcore/config/central.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class _ConfigMapping(mappings.DictMixin):
3232
any of them are remote!
3333
"""
3434

35+
__slots__ = ("manager", "typename")
3536
typename: str
3637

3738
def __init__(self, manager, typename: str) -> None:

src/pkgcore/ebuild/misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def incremental_expansion_license(
141141

142142

143143
class IncrementalsDict(mappings.DictMixin):
144-
disable_py3k_rewriting = True
144+
__slots__ = ("_dict", "_incrementals")
145145

146146
def __init__(self, incrementals, **kwds):
147147
self._incrementals = incrementals

src/pkgcore/ebuild/portage_conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def parse_file(self, f, reset=True):
9393
class PortageConfig(DictMixin):
9494
"""Support for portage's config file layout."""
9595

96+
__slots__ = ("_config", "dir", "root", "features")
9697
_supported_repo_types = {}
9798

9899
def __init__(self, location=None, profile_override=None, **kwargs):

src/pkgcore/repository/prototype.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
__all__ = ("CategoryLazyFrozenSet", "PackageMapping", "VersionMapping", "tree")
66

7-
from pathlib import Path
87
import typing
8+
from pathlib import Path
99

1010
from snakeoil.klass import jit_attr
1111
from snakeoil.mappings import DictMixin, LazyValDict
@@ -42,6 +42,8 @@ def force_regen(self):
4242

4343

4444
class PackageMapping(DictMixin):
45+
__slots__ = ("_cache", "_parent", "_pull_vals")
46+
4547
def __init__(self, parent_mapping, pull_vals):
4648
self._cache = {}
4749
self._parent = parent_mapping
@@ -67,6 +69,8 @@ def force_regen(self, cat):
6769

6870

6971
class VersionMapping(DictMixin):
72+
__slots__ = ("_cache", "_parent", "_pull_vals")
73+
7074
def __init__(self, parent_mapping, pull_vals):
7175
self._cache = {}
7276
self._parent = parent_mapping

src/pkgcore/repository/util.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ class RepositoryGroup(DictMixin):
6767
combined: combined repo, if None a multiplex repo is created
6868
"""
6969

70+
__slots__ = ("repos", "combined")
71+
7072
__externally_mutable__ = False
7173

7274
def __init__(self, repos=(), combined=None):

src/pkgcore/scripts/pclean.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ def _setup_restrictions(namespace):
257257
class _UnfilteredRepos(DictMixin):
258258
"""Generate custom, unfiltered repos on demand."""
259259

260+
__slots__ = ("domain", "unfiltered_repos")
261+
260262
_supported_attrs = {
261263
"pkg_masks",
262264
"pkg_unmasks",

0 commit comments

Comments
 (0)