Skip to content

interleave randomly #1030

@ktbarrett

Description

@ktbarrett

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions