# Path: wizzat/util.py
# def chunks(iterable, chunk_size):
#     """
#         Iterate across iterable in chunks of chunk_size
# 
#         Example:
#         for chunk in chunks(some_long_iterable, 500):
#             for element in chunk:
#                 element.perform_operation()
#     """
#     for chunk_no in range(0, len(iterable), chunk_size):
#         yield iterable[chunk_no:chunk_no+chunk_size]


from builtins import *
from future.utils import native_str, iteritems
from wizzat.decorators import *
from wizzat.util import chunks
import collections, struct, zlib

    i = 0
    while i < len(s):
        reader = readers[min((len(s)-i)//size, 250)]
        output.extend(reader.unpack_from(s, i))
        i += reader.size

    return output

bmstruct = struct.Struct(native_str('<QI'))
istructs = structs('I')
def write_int_set(itr, compress = False):
    """
    This is a space efficient serialization format for integer iterables.
    """
    parts   = collections.defaultdict(int)
    buckets = collections.defaultdict(list)

    for element in itr:
        part_idx = element // 64
        offset   = element % 64
        parts[part_idx] |= (1 << offset)

    for part_idx, bitmask in iteritems(parts):
        buckets[bitmask].append(part_idx)

    output_list = [ istructs[1].pack(len(buckets)) ]

    for bitmask, part_indexes in iteritems(buckets):
        output_list.append( bmstruct.pack(bitmask, len(part_indexes)) )

# Path: wizzat/util.py
# def chunks(iterable, chunk_size):
#     """
#         Iterate across iterable in chunks of chunk_size
# 
#         Example:
#         for chunk in chunks(some_long_iterable, 500):
#             for element in chunk:
#                 element.perform_operation()
#     """
#     for chunk_no in range(0, len(iterable), chunk_size):
#         yield iterable[chunk_no:chunk_no+chunk_size]


# Path: wizzat/serialization.py
from builtins import *
from future.utils import native_str, iteritems
from wizzat.decorators import *
from wizzat.util import chunks
import collections, struct, zlib


    i = 0
    while i < len(s):
        reader = readers[min((len(s)-i)//size, 250)]
        output.extend(reader.unpack_from(s, i))
        i += reader.size

    return output

bmstruct = struct.Struct(native_str('<QI'))
istructs = structs('I')
def write_int_set(itr, compress = False):
    """
    This is a space efficient serialization format for integer iterables.
    """
    parts   = collections.defaultdict(int)
    buckets = collections.defaultdict(list)

    for element in itr:
        part_idx = element // 64
        offset   = element % 64
        parts[part_idx] |= (1 << offset)

    for part_idx, bitmask in iteritems(parts):
        buckets[bitmask].append(part_idx)

    output_list = [ istructs[1].pack(len(buckets)) ]

    for bitmask, part_indexes in iteritems(buckets):
        output_list.append( bmstruct.pack(bitmask, len(part_indexes)) )

        for chunk in chunks(part_indexes, 250):