-
Notifications
You must be signed in to change notification settings - Fork 311
interleave randomly #1030
Copy link
Copy link
Closed
Description
Description
Interleaves multiple iterables into a single output iterable, but takes the next element from each iterable randomly. The result is an iterable where the relative order of each input iterable is preserved, but the order with respect to each other is randomized.
References
I used such a tool when generating a single stream of data from multiple independent input "channels", which is very common in networking.
Examples
data = [
[Packet(channel=ch, ...) for _ in range(packets_per_channel)]
for ch in range(num_channels)
]
stream = interleave_random(*data)
input.send(stream)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels