def chunks_known_length(iterable, size, length=None):
    """
    Yield successive `size`-sized chunks from `iterable`,
    if the length of `iterable is already known or easy to compute.

    https://stackoverflow.com/a/312464/3423324

    :param iterable: The object you want to split into pieces.

    :param size: The size each of the resulting pieces should have.
    :type  size: int

    :param length: Optional. Length of the `iterable`.
                   If set to `None` (default), the length get calculated automatically.
    :type  length: None | int
    """
    if length is None:
        len(iterable)
    for i in range(0, length, size):
        yield iterable[i:i + size]
