MCPcopy Index your code
hub / github.com/RustPython/RustPython / _interleave_addrinfos

Function _interleave_addrinfos

Lib/asyncio/base_events.py:159–178  ·  view source on GitHub ↗

Interleave list of addrinfo tuples by family.

(addrinfos, first_address_family_count=1)

Source from the content-addressed store, hash-verified

157
158
159def _interleave_addrinfos(addrinfos, first_address_family_count=1):
160 """Interleave list of addrinfo tuples by family."""
161 # Group addresses by family
162 addrinfos_by_family = collections.OrderedDict()
163 for addr in addrinfos:
164 family = addr[0]
165 if family not in addrinfos_by_family:
166 addrinfos_by_family[family] = []
167 addrinfos_by_family[family].append(addr)
168 addrinfos_lists = list(addrinfos_by_family.values())
169
170 reordered = []
171 if first_address_family_count > 1:
172 reordered.extend(addrinfos_lists[0][:first_address_family_count - 1])
173 del addrinfos_lists[0][:first_address_family_count - 1]
174 reordered.extend(
175 a for a in itertools.chain.from_iterable(
176 itertools.zip_longest(*addrinfos_lists)
177 ) if a is not None)
178 return reordered
179
180
181def _run_until_complete_cb(fut):

Callers 1

create_connectionMethod · 0.85

Calls 5

valuesMethod · 0.95
listClass · 0.85
from_iterableMethod · 0.80
appendMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected