<commit_before># -*- coding: utf-8 -*-


###############################################################################


from __future__ import division

from heapq import nlargest, nsmallest, heappush, heappop
from itertools import chain, islice, repeat
from operator import add, truediv
from re import compile as regex_compile

from six import iteritems, advance_iterator

# noinspection PyUnresolvedReferences
from six.moves import filter as ifilter, map as imap, reduce as reduce_func,\
    xrange as xxrange

from .executors import ParallelExecutor
from .iterators import seed, distinct, peek, accumulate
from .utils import ExecutorPool, MaxHeapItem, filter_map, not_predicate, \
    value_mapper, key_mapper, filter_keys, filter_values, make_list, \
    int_or_none, float_or_none, long_or_none, decimal_or_none


###############################################################################


class Stream(object):

    EXECUTORS = ExecutorPool()

    @classmethod
    def concat(cls, *streams):
        return cls(streams).chain()

    @classmethod
    def iterate(cls, function, seed_value):
        return cls(seed(function, seed_value))

    @classmethod
    def range(cls, *args, **kwargs):
        return cls(xxrange(*args, **kwargs))

    def __init__(self, iterator):
        iterator_function = iteritems if isinstance(iterator, dict) else iter
        self.iterator = iterator_function(iterator)

    def __len__(self):
        return len(self.iterator)

    def __iter__(self):
        return iter(self.iterator)

    def __reversed__(self):<commit_msg>Add collection ABCs to Stream<commit_after># -*- coding: utf-8 -*-


###############################################################################


from __future__ import division

from collections import Iterable, Sized
from heapq import nlargest, nsmallest, heappush, heappop
from itertools import chain, islice, repeat
from operator import add, truediv
from re import compile as regex_compile

from six import iteritems, advance_iterator

# noinspection PyUnresolvedReferences
from six.moves import filter as ifilter, map as imap, reduce as reduce_func,\
    xrange as xxrange

from .executors import ParallelExecutor
from .iterators import seed, distinct, peek, accumulate
from .utils import ExecutorPool, MaxHeapItem, filter_map, not_predicate, \
    value_mapper, key_mapper, filter_keys, filter_values, make_list, \
    int_or_none, float_or_none, long_or_none, decimal_or_none


###############################################################################


class Stream(Iterable, Sized):

    EXECUTORS = ExecutorPool()

    @classmethod
    def concat(cls, *streams):
        return cls(streams).chain()

    @classmethod
    def iterate(cls, function, seed_value):
        return cls(seed(function, seed_value))

    @classmethod
    def range(cls, *args, **kwargs):
        return cls(xxrange(*args, **kwargs))

    def __init__(self, iterator):
        iterator_function = iteritems if isinstance(iterator, dict) else iter
        self.iterator = iterator_function(iterator)

    def __len__(self):
        return len(self.iterator)

    def __iter__(self):
        return iter(self.iterator)

    def __reversed__(self):
{'fraction_non_alphanumeric': 0.17169517884914465, 'fraction_numerical': 0.0006220839813374805, 'mean_word_length': 4.535283993115319, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4073532', 'n_tokens_mistral': 915, 'n_tokens_neox': 876, 'n_words': 265}