Skip to content

Commit 72a2f12

Browse files
committed
Remove FeatureStructure._feats; dicts are ordered
I'm pretty sure the internal _feats list was just to ensure the order of features so reserializations of AVMs would be in the same order. This is no longer needed as dicts are now ordered in Python.
1 parent 0ac26b0 commit 72a2f12

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

delphin/tdl.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,6 @@ def __init__(self, values=None, docstring=None):
397397
tmplist = ConsList(values, end=cr)
398398
dl_list = _ImplicitAVM()
399399
dl_list._avm.update(tmplist._avm)
400-
dl_list._feats = tmplist._feats
401400
self.last = 'LIST.' + tmplist._last_path
402401
else:
403402
dl_list = cr

delphin/tfs.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,15 @@ class FeatureStructure:
3636
to feature values
3737
"""
3838

39-
__slots__ = ('_avm', '_feats')
39+
__slots__ = '_avm',
4040

4141
_avm: FeatureDict
42-
_feats: list[str]
4342

4443
def __init__(
4544
self,
4645
featvals: Union[FeatureSeq, FeatureMap, None] = None,
4746
) -> None:
4847
self._avm = {}
49-
self._feats = []
5048
if featvals and hasattr(featvals, 'items'):
5149
featvals = list(featvals.items())
5250
for feat, val in list(featvals or []):
@@ -68,8 +66,6 @@ def __setitem__(self, key: str, val: Any) -> None:
6866
avm = self._avm
6967
subkeys = key.split('.', 1)
7068
subkey = subkeys[0].upper()
71-
if subkey not in avm:
72-
self._feats.append(subkey)
7369
if len(subkeys) == 1:
7470
avm[subkey] = val
7571
else:
@@ -142,12 +138,7 @@ def features(self, expand: bool = False) -> FeatureList:
142138
"""
143139
fs = []
144140
if self._avm is not None:
145-
if len(self._feats) == len(self._avm):
146-
feats = self._feats
147-
else:
148-
feats = list(self._avm)
149-
for feat in feats:
150-
val = self._avm[feat]
141+
for feat, val in self._avm.items():
151142
if isinstance(val, FeatureStructure):
152143
if not expand and val._is_notable():
153144
fs.append((feat, val))

0 commit comments

Comments
 (0)