Commit 708875fa authored by Stefan Behnel's avatar Stefan Behnel

keep subtype definition order of fused types also for fused subtypes

avoid antipattern of sum()-ing lists
parent 152e9d58
...@@ -1339,12 +1339,16 @@ class FusedType(CType): ...@@ -1339,12 +1339,16 @@ class FusedType(CType):
exception_check = 0 exception_check = 0
def __init__(self, types, name=None): def __init__(self, types, name=None):
# Use list rather than set to preserve order. # Use list rather than set to preserve order (list should be short).
flattened_types = [t for t in types if not t.is_fused] flattened_types = []
subtypes = sum([t.types for t in types if t.is_fused], []) for t in types:
for type in subtypes: if t.is_fused:
if type not in flattened_types: # recursively merge in subtypes
flattened_types.append(type) for subtype in t.types:
if subtype not in flattened_types:
flattened_types.append(subtype)
elif t not in flattened_types:
flattened_types.append(t)
self.types = flattened_types self.types = flattened_types
self.name = name self.name = name
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment