Visualize

tinder.batch.pop(q, max_batch_size: int)[source]
tinder.batch.iter_from_q(q, max_batch_size: int)[source]
tinder.batch.iter_from_iter(iterable, batch_size, drop_last=False, total=None)[source]

Batchify given iterable.

if the given iterable has __len__(), this returns the iterable with __len()__.

Example:

import tqdm
import tinder
import time


for i in tqdm.tqdm(tinder.batch(range(100), 4, total=14)):
    print(i)
    time.sleep(0.2)


def f():
    for i in range(30):
        yield i


for i in tqdm.tqdm(tinder.batch(f(), 4)):
    print(i)
    time.sleep(0.2)
Parameters
  • iterable (iterable) –

  • batch_size (int) –

  • total (int, optional) – if None, it tries to use __len()__ of iterable.