@to_tuple
def _select_capabilities(remote_capabilities: Capabilities, local_capabilities: Capabilities) -> Iterable[Capability]:
    '\n    Select the appropriate shared capabilities between local and remote.\n\n    https://github.com/ethereum/devp2p/blob/master/rlpx.md#capability-messaging\n    '
    matching_capabilities = tuple(sorted(set(local_capabilities).intersection(remote_capabilities), key=operator.itemgetter(0)))
    sort_by_version = functools.partial(sorted, key=operator.itemgetter(1), reverse=True)
    capabilities_by_name = valmap(tuple, valmap(sort_by_version, groupby(operator.itemgetter(0), matching_capabilities)))
    for name in sorted(capabilities_by_name.keys()):
        (yield capabilities_by_name[name][0])
Select the appropriate shared capabilities between local and remote.

https://github.com/ethereum/devp2p/blob/master/rlpx.md#capability-messaging
@to_tuple
def _select_capabilities(remote_capabilities: Capabilities, local_capabilities: Capabilities) -> Iterable[Capability]:
    '\n    Select the appropriate shared capabilities between local and remote.\n\n    https://github.com/ethereum/devp2p/blob/master/rlpx.md#capability-messaging\n    '
    matching_capabilities = tuple(sorted(set(local_capabilities).intersection(remote_capabilities), key=operator.itemgetter(0)))
    sort_by_version = functools.partial(sorted, key=operator.itemgetter(1), reverse=True)
    capabilities_by_name = valmap(tuple, valmap(sort_by_version, groupby(operator.itemgetter(0), matching_capabilities)))
    for name in sorted(capabilities_by_name.keys()):
        (yield capabilities_by_name[name][0])