external_api_splits = []
for naive_internal_apis, external_apis, split in \
zip(naive_internal_api_splits, naive_external_api_splits, splits):
internal_apis = defaultdict(list)
for k, vs in naive_internal_apis.iteritems():
if k in split:
internal_apis[k] = vs // Remains internal.
else:
external_apis[representatives[k]] = vs // Externalized.
internal_api_splits.append(internal_apis)
After Change
// Split apis.
// The splits, but expressed via class representatives of the sources (see above).
representative_splits = [filter(None, [representatives.get(s) for s in srcs]) for srcs in splits]
representative_to_internal_api = {}
for src, rep in representatives.items():
representative_to_internal_api[rep] = self.apis.internal.get(src)