Commits

Lynn Rees committed 3c9c549

- back

Comments (0)

Files changed (18)

twoq/active/filtering.py

 # -*- coding: utf-8 -*-
 '''twoq active filtering queues'''
 
-from twoq.imps import LookupsMixin
 from twoq.filtering import (
     FilteringMixin, CollectMixin, SetMixin, SliceMixin)
 
 ###############################################################################
 
 
-class acollectq(LookupsMixin, AutoResultMixin, CollectMixin):
+class acollectq(AutoResultMixin, CollectMixin):
 
     '''auto-balanced collecting queue'''
 
 collectq = acollectq
 
 
-class mcollectq(LookupsMixin, ManResultMixin, CollectMixin):
+class mcollectq(ManResultMixin, CollectMixin):
 
     '''manually balanced collecting queue'''
 
 ###############################################################################
 
 
-class asetq(LookupsMixin, AutoResultMixin, SetMixin):
+class asetq(AutoResultMixin, SetMixin):
 
     '''auto-balanced set queue'''
 
 setq = asetq
 
 
-class msetq(LookupsMixin, ManResultMixin, SetMixin):
+class msetq(ManResultMixin, SetMixin):
 
     '''manually balanced set queue'''
 
 ###############################################################################
 
 
-class asliceq(LookupsMixin, AutoResultMixin, SliceMixin):
+class asliceq(AutoResultMixin, SliceMixin):
 
     '''auto-balanced slice queue'''
 
 sliceq = asliceq
 
 
-class msliceq(LookupsMixin, ManResultMixin, SliceMixin):
+class msliceq(ManResultMixin, SliceMixin):
 
     '''manually balanced slice queue'''
 
 ###############################################################################
 
 
-class afilterq(LookupsMixin, AutoResultMixin, FilteringMixin):
+class afilterq(AutoResultMixin, FilteringMixin):
 
     '''auto-balanced filter queue'''
 
 filterq = afilterq
 
 
-class mfilterq(LookupsMixin, ManResultMixin, FilteringMixin):
+class mfilterq(ManResultMixin, FilteringMixin):
 
     '''manually balanced filtering queue'''

twoq/active/mapping.py

 # -*- coding: utf-8 -*-
 '''twoq active mapping queues'''
 
-from twoq.imps import LookupsMixin
 from twoq.mapping import DelayMixin, RepeatMixin, MappingMixin
 
 from twoq.active.mixins import AutoResultMixin, ManResultMixin
 ###############################################################################
 
 
-class adelayq(LookupsMixin, AutoResultMixin, DelayMixin):
+class adelayq(AutoResultMixin, DelayMixin):
 
     '''auto-balanced delayed map queue'''
 
 delayq = adelayq
 
 
-class mdelayq(LookupsMixin, ManResultMixin, DelayMixin):
+class mdelayq(ManResultMixin, DelayMixin):
 
     '''manually balanced delayed map queue'''
 
 ###############################################################################
 
 
-class arepeatq(LookupsMixin, AutoResultMixin, RepeatMixin):
+class arepeatq(AutoResultMixin, RepeatMixin):
 
     '''auto-balanced repeat queue'''
 
 repeatq = arepeatq
 
 
-class mrepeatq(LookupsMixin, ManResultMixin, RepeatMixin):
+class mrepeatq(ManResultMixin, RepeatMixin):
 
     '''manually balanced repeat queue'''
 
 ###############################################################################
 
 
-class amapq(LookupsMixin, AutoResultMixin, MappingMixin):
+class amapq(AutoResultMixin, MappingMixin):
 
     '''auto-balanced map queue'''
 
 mapq = amapq
 
 
-class mmapq(LookupsMixin, ManResultMixin, MappingMixin):
+class mmapq(ManResultMixin, MappingMixin):
 
     '''manually balanced map queue'''

twoq/active/mixins.py

 # -*- coding: utf-8 -*-
 '''active twoq mixins'''
 
+from collections import deque
 from contextlib import contextmanager
 
 from twoq.queuing import ThingsMixin, ResultMixin
     '''base active things'''
 
     def __init__(self, *things):
-        deque_ = self._deek
+        deque_ = deque
         incoming = deque_(things[0]) if len(things) == 1 else deque_(things)
         super(BaseQMixin, self).__init__(incoming, deque_())
         # set iterator
         self._util = deque_()
 
     def __repr__(self):
-        getr_, list_ = self._getr, self._list
+        getr_, list_ = lambda x: getattr(self, x), list
         return (
             '<{}.{}([IN: {}({}) => WORK: {}({}) => UTIL: {}({}) => '
             'OUT: {}: ({})]) at {}'
 
     def __len__(self):
         '''number of incoming things'''
-        return self._len(self.incoming)
+        return len(self.incoming)
 
     def outcount(self):
         '''number of outgoing things'''
-        return self._len(self.outgoing)
+        return len(self.outgoing)
 
     ###########################################################################
     ## iterators ##############################################################
 
         @param attr: things to iterate over
         '''
-        return self.iterexcept(self._getr(attr).popleft, IndexError)
+        return self.iterexcept(getattr(self, attr).popleft, IndexError)
 
     def _breakcount(self, attr='_UTILQ'):
         '''
 
         @param attr: things to iterate over
         '''
-        dq = self._getr(attr)
-        length = len(dq)
-        return self.breakcount(dq.popleft, length, IndexError,)
+        dq = getattr(self, attr)
+        return self.breakcount(dq.popleft, len(dq), IndexError,)
 
     ###########################################################################
     ## clear things ###########################################################
 
     def _xtend(self, things):
         '''extend utility things with `things` wrapped'''
-        self._getr(self._UTILQ).extend(things)
+        getattr(self, self._UTILQ).extend(things)
         return self
 
     def _xtendleft(self, things):
         '''extend left side of utility things with `things`'''
-        self._getr(self._UTILQ).extendleft(things)
+        getattr(self, self._UTILQ).extendleft(things)
         return self
 
     def _iter(self, things):
         '''extend work things with `things` wrapped in iterator'''
-        self._getr(self._UTILQ).extend(iter(things))
+        getattr(self, self._UTILQ).extend(iter(things))
         return self
 
     ###########################################################################
 
     def _append(self, things):
         '''append `things` to utility things'''
-        self._getr(self._UTILQ).append(things)
+        getattr(self, self._UTILQ).append(things)
         return self
 
     def _appendleft(self, things):
         '''append `things` to left side of utility things'''
-        self._getr(self._UTILQ).appendleft(things)
+        getattr(self, self._UTILQ).appendleft(things)
         return self
 
     ###########################################################################
         self.swap(
             outq=kw.get(self._OUTCFG, self._INVAR), context=self.ctx2(), **kw
         )
-        getr_ = self._getr
+        getr_ = lambda x: getattr(self, x)
         outq = getr_(self._OUTQ)
         utilq = getr_(self._UTILQ)
         workq = getr_(self._WORKQ)
         self.swap(
             utilq=kw.get(self._WORKCFG, self._WORKVAR), context=self.ctx3, **kw
         )
-        getr_ = self._getr
+        getr_ = lambda x: getattr(self, x)
         outq = getr_(self._OUTQ)
         utilq = getr_(self._UTILQ)
         workq = getr_(self._WORKQ)
     def ctx4(self, **kw):
         '''swap to four-armed context'''
         self.swap(context=self.ctx4, **kw)
-        getr_ = self._getr
+        getr_ = lambda x: getattr(self, x)
         outq = getr_(self._OUTQ)
         utilq = getr_(self._UTILQ)
         workq = getr_(self._WORKQ)
     def autoctx(self, **kw):
         '''swap to auto-synchronizing context'''
         self.swap(context=self.autoctx, **kw)
-        getr_ = self._getr
+        getr_ = lambda x: getattr(self, x)
         outq = getr_(self._OUTQ)
         utilq = getr_(self._UTILQ)
         workq = getr_(self._WORKQ)
     _default_context = 'ctx4'
 
 
-class AutoResultMixin(AutoQMixin, ResultMixin):
+class EndMixin(ResultMixin):
+
+    '''result things mixin'''
+
+    def end(self):
+        '''return outgoing things then clear out everything'''
+        # return to default context
+        self.unswap()
+        wrap, outgoing = self._wrapper, self.outgoing
+        out = self.outgoing.pop() if len(outgoing) == 1 else wrap(outgoing)
+        # clear every last thing
+        self.clear()
+        return out
+
+    def value(self):
+        '''return outgoing things and clear outgoing things'''
+        # return to default context
+        self.unswap()
+        wrap, outgoing = self._wrapper, self.outgoing
+        out = self.outgoing.pop() if len(outgoing) == 1 else wrap(outgoing)
+        # clear outgoing things
+        self.outclear()
+        return out
+
+
+class AutoResultMixin(AutoQMixin, EndMixin):
 
     '''auto-balancing manipulation things (with results extractor) mixin'''
 
 
-class ManResultMixin(ManQMixin, ResultMixin):
+class ManResultMixin(ManQMixin, EndMixin):
 
     '''manually balanced things (with results extractor) mixin'''

twoq/active/ordering.py

 # -*- coding: utf-8 -*-
 '''twoq active ordering queues'''
 
-from twoq.imps import LookupsMixin
 from twoq.ordering import RandomMixin, OrderingMixin, CombineMixin
 
 from twoq.active.mixins import AutoResultMixin, ManResultMixin
 ###############################################################################
 
 
-class arandomq(LookupsMixin, AutoResultMixin, RandomMixin):
+class arandomq(AutoResultMixin, RandomMixin):
 
     '''auto-balanced random queue'''
 
 randomq = arandomq
 
 
-class mrandomq(LookupsMixin, ManResultMixin, RandomMixin):
+class mrandomq(ManResultMixin, RandomMixin):
 
     '''manually balanced random queue'''
 
 ###############################################################################
 
 
-class aorderq(LookupsMixin, AutoResultMixin, OrderingMixin):
+class aorderq(AutoResultMixin, OrderingMixin):
 
     '''auto-balanced order queue'''
 
 orderq = aorderq
 
 
-class morderq(LookupsMixin, ManResultMixin, OrderingMixin):
+class morderq(ManResultMixin, OrderingMixin):
 
     '''manually balanced order queue'''
 
 ###############################################################################
 
 
-class acombineq(LookupsMixin, AutoResultMixin, CombineMixin):
+class acombineq(AutoResultMixin, CombineMixin):
 
     '''auto-balanced combination queue'''
 
 combineq = acombineq
 
 
-class mcombineq(LookupsMixin, ManResultMixin, CombineMixin):
+class mcombineq(ManResultMixin, CombineMixin):
 
     '''manually balanced combination queue'''

twoq/active/queuing.py

 # -*- coding: utf-8 -*-
 '''twoq active queues'''
 
-from twoq.imps import LookupsMixin
 from twoq.mapping import MappingMixin as MapMixin
 from twoq.ordering import OrderingMixin as OrderMixin
 from twoq.reducing import ReducingMixin as ReduceMixin
 __all__ = ('autoq', 'manq')
 
 
-class autoq(
-    LookupsMixin, AutoResultMixin, FilterMixin, MapMixin, ReduceMixin,
-    OrderMixin,
-):
+class autoq(AutoResultMixin, FilterMixin, MapMixin, ReduceMixin, OrderMixin):
 
     '''auto-balancing manipulation queue'''
 
 
-class manq(
-    LookupsMixin, ManResultMixin, FilterMixin, MapMixin, ReduceMixin,
-    OrderMixin,
-):
+class manq(ManResultMixin, FilterMixin, MapMixin, ReduceMixin, OrderMixin):
 
     '''manually balanced manipulation queue'''
 

twoq/active/reducing.py

 # -*- coding: utf-8 -*-
 '''twoq active reducing queues'''
 
-from twoq.imps import LookupsMixin
 from twoq.reducing import MathMixin, TruthMixin, ReducingMixin
 
 from twoq.active.mixins import AutoResultMixin, ManResultMixin
 ###############################################################################
 
 
-class amathq(LookupsMixin, AutoResultMixin, MathMixin):
+class amathq(AutoResultMixin, MathMixin):
 
     '''auto-balancing math queue'''
 
 mathq = amathq
 
 
-class mmathq(LookupsMixin, ManResultMixin, MathMixin):
+class mmathq(ManResultMixin, MathMixin):
 
     '''manually balanced math queue'''
 
 ###############################################################################
 
 
-class atruthq(LookupsMixin, AutoResultMixin, TruthMixin):
+class atruthq(AutoResultMixin, TruthMixin):
 
     '''auto-balancing truth queue'''
 
 truthq = atruthq
 
 
-class mtruthq(LookupsMixin, ManResultMixin, TruthMixin):
+class mtruthq(ManResultMixin, TruthMixin):
 
     '''manually balanced truth queue'''
 
 ###############################################################################
 
 
-class areduceq(LookupsMixin, AutoResultMixin, ReducingMixin):
+class areduceq(AutoResultMixin, ReducingMixin):
 
     '''auto-balancing reduce queue'''
 
 reduceq = areduceq
 
 
-class mreduceq(LookupsMixin, ManResultMixin, ReducingMixin):
+class mreduceq(ManResultMixin, ReducingMixin):
 
     '''manually balanced reduce queue'''

twoq/filtering.py

 # -*- coding: utf-8 -*-
 '''twoq filtering mixins'''
 
+from itertools import tee, islice
 from inspect import getmro
 from threading import local
+from functools import reduce
+
 from operator import attrgetter, itemgetter, truth
 
 from stuf.six import PY3
 from stuf.utils import getcls
 
+from twoq.support import ifilter, ichain, imap, filterfalse
+
 
 class CollectMixin(local):
 
                         yield k, t(w_(f, s, t, v))
                     else:
                         yield k, v
-        for member in cls._ifilter(
+        for member in ifilter(
             truth, members(truth, subcall, transform, iterable),
         ):
             yield member
                     pass
                 else:
                     yield key, thing
-        for i in cls._ifilter(call, members(iterable)):
+        for i in ifilter(call, members(iterable)):
             yield i
 
     @staticmethod
         _mf = self._mfilter
         _mz = lambda x: _mf(self._call, x)
         if PY3:
-            def _memfilters(thing, mz=_mz, gc=getcls, ci=self._ichain):
+            def _memfilters(thing, mz=_mz, gc=getcls, ci=ichain):
                 t = lambda x: not x[0].startswith('mro')
                 return self._ifilter(
-                    t, ci(self._imap(mz, ci([getmro((gc(thing))), [thing]])))
+                    t, ci(imap(mz, ci([getmro((gc(thing))), [thing]])))
                 )
         else:
-            def _memfilters(thing, mz=_mz, gc=getcls, ci=self._ichain):
-                return ci(self._imap(mz, ci([getmro((gc(thing))), [thing]])))
+            def _memfilters(thing, mz=_mz, gc=getcls, ci=ichain):
+                return ci(imap(mz, ci([getmro((gc(thing))), [thing]])))
         with self._context():
             return self._xtend(
-                self._ichain(self._imap(_memfilters, self._iterable))
+                ichain(imap(_memfilters, self._iterable))
             )
             
     def extract(self):
         with self._context():
             walk_ = self._extract
             call_, alt_, wrap_ = self._call, self._alt, self._wrapper
-            return self._xtend(self._ichain(self._imap(
+            return self._xtend(ichain(imap(
                 lambda x: walk_(call_, alt_, wrap_, x), self._iterable,
             )))
 
     def members(self):
         '''collect object members from incoming things'''
         with self._context():
-            return self._xtend(self._ichain(self._imap(
-                self._partial(self._mfilter, self._call), self._iterable,
+            mfilter = self._mfilter
+            return self._xtend(ichain(imap(
+                lambda x: mfilter(self._call, x), self._iterable,
             )))
 
     def pick(self, *names):
         seen = set()
         seen_add_, seen_contains_ = seen.add, seen.__contains__
         if key is None:
-            for element in cls._filterfalse(seen_contains_, iterable):
+            for element in filterfalse(seen_contains_, iterable):
                 seen_add_(element)
                 yield element
         else:
     def difference(self):
         '''difference between incoming things'''
         with self._context():
-            return self._xtend(self._ireduce(
+            return self._xtend(reduce(
                 lambda x, y: set(x).difference(y), self._iterable,
             ))
 
     def symmetric_difference(self):
         '''symmetric difference between incoming things'''
         with self._context():
-            return self._xtend(self._ireduce(
+            return self._xtend(reduce(
                 lambda x, y: set(x).symmetric_difference(y), self._iterable,
             ))
 
     def disjointed(self):
         '''disjoint between incoming things'''
         with self._context():
-            return self._append(self._ireduce(
+            return self._append(reduce(
                 lambda x, y: set(x).isdisjoint(y), self._iterable,
             ))
 
     def intersection(self):
         '''intersection between incoming things'''
         with self._context():
-            return self._xtend(self._ireduce(
+            return self._xtend(reduce(
                 lambda x, y: set(x).intersection(y), self._iterable,
             ))
 
     def subset(self):
         '''incoming things that are subsets of incoming things'''
         with self._context():
-            return self._append(self._ireduce(
+            return self._append(reduce(
                 lambda x, y: set(x).issubset(y), self._iterable,
             ))
 
     def superset(self):
         '''incoming things that are supersets of incoming things'''
         with self._context():
-            return self._append(self._ireduce(
+            return self._append(reduce(
                 lambda x, y: set(x).issubset(y), self._iterable
             ))
 
         '''union between incoming things'''
         with self._context():
             return self._xtend(
-                self._ireduce(lambda x, y: set(x).union(y), self._iterable)
+                reduce(lambda x, y: set(x).union(y), self._iterable)
             )
 
     def unique(self):
         '''
         with self._context():
             return self._append(
-                self._next(self._islice(self._iterable, n, None), default)
+                next(islice(self._iterable, n, None), default)
             )
 
     def initial(self):
         '''all incoming things except the last thing'''
         with self._context():
-            i1, i2 = self._split(self._iterable)
-            return self._xtend(self._islice(i1, len(list(i2)) - 1))
+            i1, i2 = tee(self._iterable)
+            return self._xtend(islice(i1, len(list(i2)) - 1))
 
     def rest(self):
         '''all incoming things except the first thing'''
         with self._context():
-            return self._xtend(self._islice(self._iterable, 1, None))
+            return self._xtend(islice(self._iterable, 1, None))
 
     def snatch(self, n):
         '''
         @param n: number of things
         '''
         with self._context():
-            i1, i2 = self._split(self._iterable)
-            return self._xtend(self._islice(
-                i1, self._len(self._list(i2)) - n, None
-            ))
+            i1, i2 = tee(self._iterable)
+            return self._xtend(islice(i1, len(list(i2)) - n, None))
 
     def take(self, n):
         '''
         @param n: number of things
         '''
         with self._context():
-            return self._xtend(self._islice(self._iterable, n))
+            return self._xtend(islice(self._iterable, n))
 
 
 class FilterMixin(local):
     def compact(self):
         '''strip "untrue" things from incoming things'''
         with self._context():
-            return self._iter(self._ifilter(truth, self._iterable))
+            return self._iter(ifilter(truth, self._iterable))
 
     def filter(self):
         '''incoming things for which call is `True`'''
         with self._context():
-            return self._xtend(self._ifilter(self._call, self._iterable))
+            return self._xtend(ifilter(self._call, self._iterable))
 
     def find(self):
         '''first incoming thing for which call is `True`'''
         with self._context():
             return self._append(
-                self._next(self._ifilter(self._call, self._iterable))
+                next(ifilter(self._call, self._iterable))
             )
 
     def partition(self):
         split incoming things into `True` and `False` things based on results
         of call
         '''
-        list_, call_ = self._list, self._call
+        list_, call_ = list, self._call
         with self._context():
-            falsy, truey = self._split(self._iterable)
-            return self._xtend(self._iterz([
-                list_(self._filterfalse(call_, falsy)),
-                list_(self._ifilter(call_, truey)),
+            falsy, truey = tee(self._iterable)
+            return self._xtend(iter([
+                list_(filterfalse(call_, falsy)), list_(ifilter(call_, truey)),
             ]))
 
     def reject(self):
         '''incoming things for which call is `False`'''
         with self._context():
-            return self._xtend(self._filterfalse(self._call, self._iterable))
+            return self._xtend(filterfalse(self._call, self._iterable))
 
     def without(self, *things):
         '''strip things from incoming things'''
         with self._context():
             return self._xtend(
-                self._filterfalse(lambda y: y in things, self._iterable)
+                filterfalse(lambda y: y in things, self._iterable)
             )
 
 

twoq/imps.py

-# -*- coding: utf-8 -*-
-'''twoq lookup mixins'''
-
-import time
-import operator
-import itertools
-import functools
-from math import fsum
-from threading import local
-from random import choice, shuffle, sample
-
-from twoq import support
-from collections import deque
-from operator import methodcaller
-from stuf.utils import lazy, clsname, lazy_class
-
-
-class lazier(lazy_class):
-
-    def __init__(self, method):
-        super(lazier, self).__init__(lambda x: method)
-
-
-class LookupsMixin(local):
-
-    '''lookup mixins'''
-
-    _choice = lazier(choice)
-    _clsname = lazier(clsname)
-    _contains = lazier(operator.contains)
-    _counter = lazier(support.Counter)
-    _deek = lazier(deque)
-    _filterfalse = lazier(support.filterfalse)
-    _fsum = lazier(fsum)
-    _groupby = lazier(itertools.groupby)
-    _ichain = lazier(itertools.chain.from_iterable)
-    _ifilter = lazier(support.ifilter)
-    _imap = lazier(support.imap)
-    _ireduce = lazier(functools.reduce)
-    _islice = lazier(itertools.islice)
-    _items = lazier(support.items)
-    _join = lazier(itertools.chain)
-    _methodcaller = lazier(methodcaller)
-    _partial = lazier(functools.partial)
-    _range = lazier(support.range)
-    _repeat = lazier(itertools.repeat)
-    _reversed = lazier(reversed)
-    _sample = lazier(sample)
-    _shuffle = lazier(shuffle)
-    _sleep = lazier(time.sleep)
-    _split = lazier(itertools.tee)
-    _starmap = lazier(itertools.starmap)
-    _truediv = lazier(operator.truediv)
-    _zip = lazier(zip)
-
-    @lazy
-    def _getr(self):
-        '''local getter'''
-        return self._partial(local.__getattribute__, self)
-
-    @lazy
-    def _setr(self):
-        '''local setter'''
-        return self._partial(local.__setattr__, self)
-
-    @lazy
-    def _delr(self):
-        '''local deleter'''
-        return self._partial(local.__delattr__, self)

twoq/lazy/filtering.py

 # -*- coding: utf-8 -*-
 '''twoq lazy filtering queues'''
 
-from twoq.imps import LookupsMixin
 from twoq.filtering import (
     FilteringMixin, CollectMixin, SetMixin, SliceMixin)
 
 ###############################################################################
 
 
-class acollectq(LookupsMixin, AutoResultMixin, CollectMixin):
+class acollectq(AutoResultMixin, CollectMixin):
 
     '''auto-balanced collecting queue'''
 
 collectq = acollectq
 
 
-class mcollectq(LookupsMixin, ManResultMixin, CollectMixin):
+class mcollectq(ManResultMixin, CollectMixin):
 
     '''manually balanced collecting queue'''
 
 ###############################################################################
 
 
-class asetq(LookupsMixin, AutoResultMixin, SetMixin):
+class asetq(AutoResultMixin, SetMixin):
 
     '''auto-balanced set queue'''
 
 setq = asetq
 
 
-class msetq(LookupsMixin, ManResultMixin, SetMixin):
+class msetq(ManResultMixin, SetMixin):
 
     '''manually balanced set queue'''
 
 ###############################################################################
 
 
-class asliceq(LookupsMixin, AutoResultMixin, SliceMixin):
+class asliceq(AutoResultMixin, SliceMixin):
 
     '''auto-balanced slice queue'''
 
 sliceq = asliceq
 
 
-class msliceq(LookupsMixin, ManResultMixin, SliceMixin):
+class msliceq(ManResultMixin, SliceMixin):
 
     '''manually balanced slice queue'''
 
 ###############################################################################
 
 
-class afilterq(LookupsMixin, AutoResultMixin, FilteringMixin):
+class afilterq(AutoResultMixin, FilteringMixin):
 
     '''auto-balanced filter queue'''
 
 filterq = afilterq
 
 
-class mfilterq(LookupsMixin, ManResultMixin, FilteringMixin):
+class mfilterq(ManResultMixin, FilteringMixin):
 
     '''manually balanced filtering queue'''

twoq/lazy/mapping.py

 # -*- coding: utf-8 -*-
 '''twoq lazy mapping queues'''
 
-from twoq.imps import LookupsMixin
 from twoq.mapping import DelayMixin, RepeatMixin, MappingMixin
 
 from twoq.lazy.mixins import AutoResultMixin, ManResultMixin
 ###############################################################################
 
 
-class adelayq(LookupsMixin, AutoResultMixin, DelayMixin):
+class adelayq(AutoResultMixin, DelayMixin):
 
     '''auto-balanced delayed map queue'''
 
 delayq = adelayq
 
 
-class mdelayq(LookupsMixin, ManResultMixin, DelayMixin):
+class mdelayq(ManResultMixin, DelayMixin):
 
     '''manually balanced delayed map queue'''
 
 ###############################################################################
 
 
-class arepeatq(LookupsMixin, AutoResultMixin, RepeatMixin):
+class arepeatq(AutoResultMixin, RepeatMixin):
 
     '''auto-balanced repeat queue'''
 
 repeatq = arepeatq
 
 
-class mrepeatq(LookupsMixin, ManResultMixin, RepeatMixin):
+class mrepeatq(ManResultMixin, RepeatMixin):
 
     '''manually balanced repeat queue'''
 
 ###############################################################################
 
 
-class amapq(LookupsMixin, AutoResultMixin, MappingMixin):
+class amapq(AutoResultMixin, MappingMixin):
 
     '''auto-balanced map queue'''
 
 mapq = amapq
 
 
-class mmapq(LookupsMixin, ManResultMixin, MappingMixin):
+class mmapq(ManResultMixin, MappingMixin):
 
     '''manually balanced map queue'''

twoq/lazy/mixins.py

 # -*- coding: utf-8 -*-
 '''lazy twoq mixins'''
 
+from itertools import tee, chain
 from contextlib import contextmanager
 
 from twoq.queuing import ResultMixin, ThingsMixin
     '''base lazy things'''
 
     def __init__(self, *things):
-        iter_ = self._iterz
+        iter_ = iter
         incoming = iter_([things[0]]) if len(things) == 1 else iter_(things)
         super(BaseQMixin, self).__init__(incoming, iter_([]))
         # work things
         self._util = iter_([])
 
     def __repr__(self):
-        getr_, setr_, list_ = self._getr, self._setr, self._list
-        in1, in2 = self._split(getr_(self._INQ))
+        list_, tee_ = list, tee
+        setr_ = lambda x, y: setattr(self, x, y)
+        getr_ = lambda x: getattr(self, x)
+        in1, in2 = tee_(getr_(self._INQ))
         setr_(self._INQ, in1)
-        out1, out2 = self._split(getr_(self._OUTQ))
+        out1, out2 = tee_(getr_(self._OUTQ))
         setr_(self._OUTQ, out1)
-        work1, work2 = self._split(getr_(self._WORKQ))
+        work1, work2 = tee_(getr_(self._WORKQ))
         setr_(self._WORKQ, work1)
-        util1, util2 = self._split(getr_(self._UTILQ))
+        util1, util2 = tee_(getr_(self._UTILQ))
         setr_(self._UTILQ, util1)
         return (
             '<{}.{}([IN: {}({}) => WORK: {}({}) => UTIL: {}({}) => '
 
     def __len__(self):
         '''number of incoming things'''
-        self.incoming, incoming = self._split(self.incoming)
-        return self._len(self._list(incoming))
+        self.incoming, incoming = tee(self.incoming)
+        return len(list(incoming))
 
     def outcount(self):
         '''number of outgoing things'''
-        self.outgoing, outgoing = self._split(self.outgoing)
-        return self._len(self._list(outgoing))
+        self.outgoing, outgoing = tee(self.outgoing)
+        return len(list(outgoing))
 
     ###########################################################################
     ## iterators ##############################################################
 
     def __iter__(self):
         '''yield outgoing things, clearing outgoing things as it iterates'''
-        return self._getr(self._OUTQ)
+        return getattr(self, self._OUTQ)
 
     @property
     def _iterable(self):
         '''iterable'''
-        return self._getr(self._WORKQ)
+        return getattr(self, self._WORKQ)
 
     ###########################################################################
     ## clear things ###########################################################
 
     def _clearwork(self):
         '''clear work things and utility things'''
-        iter_ = self._iterz
-        setr_, delr_ = self._setr, self._delr
+        iter_ = iter
+        setr_ = lambda x, y: setattr(self, x, y)
+        delr_ = lambda x: delattr(self, x)
         WORKQ, UTILQ = self._WORKQ, self._UTILQ
         # clear work things
         delr_(WORKQ)
     def _uclear(self):
         '''clear utility things'''
         UTILQ = self._UTILQ
-        self._delr(UTILQ)
-        self._setr(UTILQ, self._iterz([]))
+        delattr(self, UTILQ)
+        setattr(self, UTILQ, iter([]))
         return self
 
     def _wclear(self):
         '''clear work things'''
         WORKQ = self._WORKQ
-        self._delr(WORKQ)
-        self._setr(WORKQ, self._iterz([]))
+        delattr(self, WORKQ)
+        setattr(self, WORKQ, iter([]))
         return self
 
     def inclear(self):
         '''clear incoming things'''
         INQ = self._INQ
-        self._delr(INQ)
-        self._setr(INQ, self._iterz([]))
+        delattr(self, INQ)
+        setattr(self, INQ, iter([]))
         return self
 
     def outclear(self):
         '''clear outgoing things'''
         OUTQ = self._OUTQ
-        self._delr(OUTQ)
-        self._setr(OUTQ, self._iterz([]))
+        delattr(self, OUTQ)
+        setattr(self, OUTQ, iter([]))
         return self
 
     ###########################################################################
     def _xtend(self, thing):
         '''build chain'''
         UTILQ = self._UTILQ
-        self._setr(UTILQ, self._join(thing, self._getr(UTILQ)))
+        setattr(self, UTILQ, chain(thing, getattr(self, UTILQ)))
         return self
 
     __buildchain = _xtend
 
     def _xtendleft(self, things):
         '''extend left side of work things with `things`'''
-        return self.__buildchain(self._reversed(things))
+        return self.__buildchain(reversed(things))
 
     def _xreplace(self, thing):
         '''build chain'''
-        self._setr(self._UTILQ, thing)
+        setattr(self, self._UTILQ, thing)
         return self
 
     def _iter(self, things):
 
     def _append(self, things):
         '''append `things` to work things'''
-        return self.__buildchain(self._iterz([things]))
+        return self.__buildchain(iter([things]))
 
     def _appendleft(self, things):
         '''append `things` to left side of work things'''
-        return self.__buildchain(self._iterz([things]))
+        return self.__buildchain(iter([things]))
 
     ###########################################################################
     ## context rotation #######################################################
         self.swap(
             context=self.ctx2, outq=kw.get(self._OUTCFG, self._INVAR), **kw
         )._clearwork()
-        setr_, getr_, OUTQ = self._setr, self._getr, self._OUTQ
+        setr_ = lambda x, y: setattr(self, x, y)
+        getr_ = lambda x: getattr(self, x)
+        OUTQ = self._OUTQ
         # extend work things with outgoing things
-        work, out = self._split(getr_(OUTQ))
+        work, out = tee(getr_(OUTQ))
         setr_(self._WORKQ, work)
         setr_(OUTQ, out)
         yield
         util = getr_(self._UTILQ)
         setr_(
             self._OUTQ,
-            util if self._clearout else self._join(util, getr_(self._OUTQ)),
+            util if self._clearout else chain(util, getr_(self._OUTQ)),
         )
         self._clearwork()
         # return to global context
         self.swap(
             utilq=kw.get(self._WORKCFG, self._WORKVAR), context=self.ctx3, **kw
         )._clearwork()
-        setr_, getr_, INQ = self._setr, self._getr, self._INQ
+        setr_ = lambda x, y: setattr(self, x, y)
+        getr_ = lambda x: getattr(self, x)
+        INQ = self._INQ
         # extend work things with incoming things
-        work, inq = self._split(getr_(INQ))
+        work, inq = tee(getr_(INQ))
         setr_(self._WORKQ, work)
         setr_(INQ, inq)
         yield
         util = getr_(self._UTILQ)
         setr_(
             self._OUTQ,
-            util if self._clearout else self._join(util, getr_(self._OUTQ)),
+            util if self._clearout else chain(util, getr_(self._OUTQ)),
         )
         self._clearwork()
         # return to global context
     def ctx4(self, **kw):
         '''swap to four-armed context'''
         self.swap(context=self.ctx4, **kw)._clearwork()
-        setr_, getr_, INQ = self._setr, self._getr, self._INQ
+        setr_ = lambda x, y: setattr(self, x, y)
+        getr_ = lambda x: getattr(self, x)
+        INQ = self._INQ
         # extend work things with incoming things
-        work, inq = self._split(getr_(INQ))
+        work, inq = tee(getr_(INQ))
         setr_(self._WORKQ, work)
         setr_(INQ, inq)
         yield
         util = getr_(self._UTILQ)
         setr_(
             self._OUTQ,
-            util if self._clearout else self._join(util, getr_(self._OUTQ)),
+            util if self._clearout else chain(util, getr_(self._OUTQ)),
         )
         self._clearwork()
         # return to global context
     def autoctx(self, **kw):
         '''swap to auto-synchronizing context'''
         self.swap(context=self.autoctx, **kw)._clearwork()
-        setr_, getr_ = self._setr, self._getr
-        INQ, split_ = self._INQ, self._split
+        setr_ = lambda x, y: setattr(self, x, y)
+        getr_ = lambda x: getattr(self, x)
+        INQ = self._INQ
         # extend work things with incoming things
-        work, inq = self._split(getr_(INQ))
+        work, inq = tee(getr_(INQ))
         setr_(self._WORKQ, work)
         setr_(INQ, inq)
         yield
         # extend incoming things and outgoing things with utility things
-        inq, out = split_(getr_(self._UTILQ))
+        inq, out = tee(getr_(self._UTILQ))
         setr_(
             self._OUTQ,
-            out if self._clearout else self._join(out, getr_(self._OUTQ)),
+            out if self._clearout else chain(out, getr_(self._OUTQ)),
         )
         setr_(INQ, inq)
         self._clearwork()
     '''manually balanced things mixin'''
 
     _default_context = 'ctx4'
+    
+    
+class EndMixin(ResultMixin):
 
+    '''result things mixin'''
 
-class AutoResultMixin(ResultMixin, AutoQMixin):
+    def end(self):
+        '''return outgoing things then clear out everything'''
+        # return to default context
+        self.unswap()
+        out, tell = tee(self.outgoing)
+        wrap = self._wrapper
+        out = next(out) if len(wrap(tell)) == 1 else wrap(out)
+        # clear every last thing
+        self.clear()
+        return out
+
+    def value(self):
+        '''return outgoing things and clear outgoing things'''
+        # return to default context
+        self.unswap()
+        out, tell = tee(self.outgoing)
+        wrap = self._wrapper
+        out = next(out) if len(wrap(tell)) == 1 else wrap(out)
+        # clear outgoing things
+        self.outclear()
+        return out
+
+
+class AutoResultMixin(EndMixin, AutoQMixin):
 
     '''auto-balancing things (with results extraction) mixin'''
 
 
-class ManResultMixin(ResultMixin, ManQMixin):
+class ManResultMixin(EndMixin, ManQMixin):
 
     '''manually balanced things (with results extraction) mixin'''

twoq/lazy/ordering.py

 # -*- coding: utf-8 -*-
 '''twoq lazy ordering queues'''
 
-from twoq.imps import LookupsMixin
 from twoq.ordering import RandomMixin, OrderingMixin, CombineMixin
 
 from twoq.lazy.mixins import AutoResultMixin, ManResultMixin
 ###############################################################################
 
 
-class arandomq(LookupsMixin, AutoResultMixin, RandomMixin):
+class arandomq(AutoResultMixin, RandomMixin):
 
     '''auto-balanced random queue'''
 
 randomq = arandomq
 
 
-class mrandomq(LookupsMixin, ManResultMixin, RandomMixin):
+class mrandomq(ManResultMixin, RandomMixin):
 
     '''manually balanced random queue'''
 
 ###############################################################################
 
 
-class aorderq(LookupsMixin, AutoResultMixin, OrderingMixin):
+class aorderq(AutoResultMixin, OrderingMixin):
 
     '''auto-balanced order queue'''
 
 orderq = aorderq
 
 
-class morderq(LookupsMixin, ManResultMixin, OrderingMixin):
+class morderq(ManResultMixin, OrderingMixin):
 
     '''manually balanced order queue'''
 
 ###############################################################################
 
 
-class acombineq(LookupsMixin, AutoResultMixin, CombineMixin):
+class acombineq(AutoResultMixin, CombineMixin):
 
     '''auto-balanced combination queue'''
 
 combineq = acombineq
 
 
-class mcombineq(LookupsMixin, ManResultMixin, CombineMixin):
+class mcombineq(ManResultMixin, CombineMixin):
 
     '''manually balanced combination queue'''

twoq/lazy/queuing.py

 # -*- coding: utf-8 -*-
 '''twoq lazy queues'''
 
-from twoq.imps import LookupsMixin
 from twoq.mapping import MappingMixin as MapMixin
 from twoq.ordering import OrderingMixin as OrderMixin
 from twoq.reducing import ReducingMixin as ReduceMixin
 __all__ = ('autoq', 'manq', 'twoq')
 
 
-class autoq(
-    LookupsMixin, AutoResultMixin, FilterMixin, MapMixin, ReduceMixin,
-    OrderMixin,
-):
+class autoq(AutoResultMixin, FilterMixin, MapMixin, ReduceMixin, OrderMixin):
 
     '''auto-balancing manipulation queue'''
 
 
-class manq(
-    LookupsMixin, ManResultMixin, FilterMixin, MapMixin, ReduceMixin,
-    OrderMixin,
-):
+class manq(ManResultMixin, FilterMixin, MapMixin, ReduceMixin, OrderMixin):
 
     '''manually balanced manipulation queue'''
 

twoq/lazy/reducing.py

 # -*- coding: utf-8 -*-
 '''twoq lazy reducing queues'''
 
-from twoq.imps import LookupsMixin
 from twoq.reducing import MathMixin, TruthMixin, ReducingMixin
 
 from twoq.lazy.mixins import AutoResultMixin, ManResultMixin
 ###############################################################################
 
 
-class amathq(LookupsMixin, AutoResultMixin, MathMixin):
+class amathq(AutoResultMixin, MathMixin):
 
     '''auto-balancing math queue'''
 
 mathq = amathq
 
 
-class mmathq(LookupsMixin, ManResultMixin, MathMixin):
+class mmathq(ManResultMixin, MathMixin):
 
     '''manually balanced math queue'''
 
 ###############################################################################
 
 
-class atruthq(LookupsMixin, AutoResultMixin, TruthMixin):
+class atruthq(AutoResultMixin, TruthMixin):
 
     '''auto-balancing truth queue'''
 
 truthq = atruthq
 
 
-class mtruthq(LookupsMixin, ManResultMixin, TruthMixin):
+class mtruthq(ManResultMixin, TruthMixin):
 
     '''manually balanced truth queue'''
 
 ###############################################################################
 
 
-class areduceq(LookupsMixin, AutoResultMixin, ReducingMixin):
+class areduceq(AutoResultMixin, ReducingMixin):
 
     '''auto-balancing reduce queue'''
 
 reduceq = areduceq
 
 
-class mreduceq(LookupsMixin, ManResultMixin, ReducingMixin):
+class mreduceq(ManResultMixin, ReducingMixin):
 
     '''manually balanced reduce queue'''
 # -*- coding: utf-8 -*-
 '''twoq mapping mixins'''
 
+from time import sleep
 from copy import deepcopy
 from threading import local
+from operator import methodcaller
+from itertools import starmap, tee, repeat
+
+from twoq.support import imap, ichain, items, xrange
 
 
 class DelayMixin(local):
 
     '''delayed map mixin'''
 
-    @classmethod
-    def _delay_each(cls, x, y, wait=0, caller=None):
+    @staticmethod
+    def _delay_each(x, y, wait=0, caller=None):
         '''
         invoke `caller` with passed arguments, keywords after a delay
 
         @param wait: time in seconds to delay (default: 0)
         @param caller: a callable (default: None)
         '''
-        cls._sleep(wait)
+        sleep(wait)
         return caller(*x, **y)
 
-    @classmethod
-    def _delay_invoke(cls, x, wait=0, caller=None):
+    @staticmethod
+    def _delay_invoke(x, wait=0, caller=None):
         '''
         invoke method on object after a delay but return object instead of call
         result if the call returns None
         @param wait: time in seconds to delay (default: 0)
         @param caller: a callable (default: None)
         '''
-        cls._sleep(wait)
+        sleep(wait)
         results = caller(x)
         return x if results is None else results
 
-    @classmethod
-    def _delay_map(cls, x, wait=None, caller=None):
+    @staticmethod
+    def _delay_map(x, wait=None, caller=None):
         '''
         invoke call on thing after a delay
 
         @param wait: time in seconds to delay (default: 0)
         @param caller: a callable (default: None)
         '''
-        cls._sleep(wait)
+        sleep(wait)
         return caller(x)
 
     def delay_each(self, wait):
         @param wait: time in seconds
         '''
         with self._context():
-            return self._xtend(self._starmap(self._partial(
-                self._delay_each, wait=wait, caller=self._call
-            ), self._iterable))
+            de, call = self._delay_each, self._call
+            return self._xtend(starmap(
+                lambda x, y: de(x, y, wait, call), self._iterable,
+            ))
 
     def delay_invoke(self, name, wait):
         '''
         @param wait: time in seconds
         '''
         with self._context():
-            return self._xtend(self._imap(self._partial(
-                self._delay_invoke,
-                wait=wait,
-                caller=self._methodcaller(name, *self._args, **self._kw),
-            ), self._iterable))
+            di, mc = self._delay_invoke, methodcaller
+            args, kw = self._args, self._kw
+            return self._xtend(imap(
+                lambda x: di(x, wait, mc(name, *args, **kw)), self._iterable,
+            ))
 
     def delay_map(self, wait):
         '''
         @param wait: time in seconds
         '''
         with self._context():
-            return self._xtend(self._imap(self._partial(
-                self._delay_map, wait=wait, caller=self._call
-            ), self._iterable))
+            dm, call = self._delay_map, self._call
+            return self._xtend(imap(
+                lambda x: dm(x, wait, call), self._iterable,
+            ))
 
 
 class RepeatMixin(local):
     def copy(self):
         '''copy each incoming thing'''
         with self._context():
-            return self._xtend(self._imap(deepcopy, self._iterable))
+            return self._xtend(imap(deepcopy, self._iterable))
 
     def padnone(self):
         '''repeat incoming things and then `None` indefinitely'''
         with self._context():
-            return self._iter(
-                self._join(self._iterable, self._repeat(None),
-            ))
+            return self._iter(tee(self._iterable, repeat(None)))
 
     def range(self, start, stop=0, step=1):
         '''
         '''
         with self._context():
             return self._xtend(
-                self._range(start, stop, step) if stop else self._range(start)
+                xrange(start, stop, step) if stop else xrange(start)
             )
 
     def repeat(self, n):
         @param n: number of times to repeat
         '''
         with self._context():
-            return self._xtend(self._repeat(tuple(self._iterable), n))
+            return self._xtend(repeat(tuple(self._iterable), n))
 
     def times(self, n=None):
         '''
         '''
         with self._context():
             if n is None:
-                return self._xtend(self._starmap(
-                    self._call, self._repeat(self._list(self._iterable)),
+                return self._xtend(starmap(
+                    self._call, repeat(list(self._iterable)),
                 ))
-            return self._xtend(self._starmap(
-                self._call, self._repeat(self._list(self._iterable), n),
+            return self._xtend(starmap(
+                self._call, repeat(list(self._iterable), n),
             ))
 
 
     def map(self):
         '''invoke call on each incoming thing'''
         with self._context():
-            return self._xtend(self._imap(self._call, self._iterable))
+            return self._xtend(imap(self._call, self._iterable))
 
     def invoke(self, name):
         '''
         @param name: name of method
         '''
         with self._context():
-            return self._xtend(self._imap(self._partial(
-                self._invoke,
-                caller=self._methodcaller(name, *self._args, **self._kw),
-            ), self._iterable))
+            invoke = self._invoke
+            return self._xtend(imap(
+                lambda x: invoke(
+                    x, caller=methodcaller(name, *self._args, **self._kw)
+                ),
+                self._iterable
+            ))
 
     def each(self):
         '''invoke call with passed arguments, keywords in incoming things'''
         with self._context():
-            return self._xtend(self._starmap(
+            return self._xtend(starmap(
                 lambda x, y: self._call(*x, **y), self._iterable,
             ))
 
     def starmap(self):
         '''invoke call on each sequence of incoming things'''
         with self._context():
-            return self._xtend(self._starmap(self._call, self._iterable))
+            return self._xtend(starmap(self._call, self._iterable))
 
     def items(self):
         '''invoke call on each mapping to get key, value pairs'''
         with self._context():
-            return self._xtend(self._starmap(
-                self._call,
-                self._ichain(self._imap(self._items, self._iterable))
+            return self._xtend(starmap(
+                self._call, ichain(imap(items, self._iterable))
             ))
 
 
 '''twoq ordering mixins'''
 
 from threading import local
-from itertools import product
+from itertools import product, groupby
+from random import choice, shuffle, sample
 
-from twoq.support import zip_longest
+from twoq.support import zip_longest, imap
 
 
 class RandomMixin(local):
     def choice(self):
         '''random choice of/from incoming things'''
         with self._context():
-            return self._append(self._choice(self._list(self._iterable)))
+            return self._append(choice(list(self._iterable)))
 
     def sample(self, n):
         '''
         @param n: number of incoming things
         '''
         with self._context():
-            return self._xtend(self._sample(self._list(self._iterable), n))
+            return self._xtend(sample(list(self._iterable), n))
 
     def shuffle(self):
         '''randomly order incoming things'''
         with self._context():
-            iterable = self._list(self._iterable)
-            self._shuffle(iterable)
+            iterable = list(self._iterable)
+            shuffle(iterable)
             return self._xtend(iterable)
 
 
         '''
         group incoming things, optionally using current call for key function
         '''
-        call_, list_ = self._call, self._list
+        call_, list_ = self._call, list
         with self._context():
             if call_ is None:
-                return self._xtend(self._imap(
-                    lambda x: [x[0], list_(x[1])],
-                    self._groupby(self._iterable),
+                return self._xtend(imap(
+                    lambda x: [x[0], list_(x[1])], groupby(self._iterable),
                 ))
-            return self._xtend(self._imap(
-                lambda x: [x[0], list_(x[1])],
-                self._groupby(self._iterable, call_)
+            return self._xtend(imap(
+                lambda x: [x[0], list_(x[1])], groupby(self._iterable, call_)
             ))
 
     def grouper(self, n, fill=None):
         '''
         with self._context():
             return self._xtend(
-                zip_longest(fillvalue=fill, *[self._iterz(self._iterable)] * n)
+                zip_longest(fillvalue=fill, *[iter(self._iterable)] * n)
             )
 
     def reverse(self):
         '''reverse order of incoming things'''
         with self._context():
-            return self._xtend(self._reversed(self._list(self._iterable)))
+            return self._xtend(reversed(list(self._iterable)))
 
     def sort(self):
         '''
         call_ = self._call
         with self._context():
             if call_ is None:
-                return self._xtend(self._sorted(self._iterable))
-            return self._xtend(self._sorted(self._iterable, key=call_))
+                return self._xtend(sorted(self._iterable))
+            return self._xtend(sorted(self._iterable, key=call_))
 
 
 class CombineMixin(local):
 '''twoq queuing mixins'''
 
 from threading import local
+from collections import deque
+from itertools import tee, starmap, repeat
 from contextlib import contextmanager
 
+from support import ifilter, items
+
 
 class ThingsMixin(local):
 
 
     def swap(self, hard=False, **kw):
         '''swap contexts'''
-        self._context = kw.get('context', self._getr(self._default_context))
+        self._context = kw.get('context', getattr(self, self._default_context))
         # clear out outgoing things before extending them?
         self._clearout = kw.get('clearout', True)
         # keep context-specific settings between context swaps
     
     def unwrap(self):
         '''clear current wrapper'''
-        self._wrapper = self._list
+        self._wrapper = list
         return self
 
     ###########################################################################
     def reup(self):
         '''put incoming things in incoming things as one incoming thing'''
         with self.ctx2():
-            return self._append(self._list(self._iterable))
+            return self._append(list(self._iterable))
 
     def shift(self):
         '''shift outgoing things to incoming things'''
 
         @param iterable: an iterable to exhaust
         '''
-        for i in cls._repeat(None, length):  # @UnusedVariable
+        for i in repeat(None, length):  # @UnusedVariable
             try:
                 yield call()
             except exception:
         @param iterable: iterable to exhaust
         @param exception: exception marking end of iteration
         '''
-        next_ = self._next
+        next_ = next
         try:
             while 1:
                 next_(iterable)
         @param filter: a filter to apply to mapping (default: `None`)
         @param exception: exception sentinel (default: `StopIteration`)
         '''
-        next_, items = self._next, self._items
-        iterable = self._starmap(
-            call, self._ifilter(filter, items(maps)) if filter else items(maps)
+        next_ = next
+        iterable = starmap(
+            call, ifilter(filter, items(maps)) if filter else items(maps)
         )
         try:
             while 1:
         '''return outgoing things then clear out everything'''
         # return to default context
         self.unswap()
-        out, tell = self._split(self.outgoing)
+        out, tell = tee(self.outgoing)
         wrap = self._wrapper
-        out = self._next(out) if self._len(wrap(tell)) == 1 else wrap(out)
+        out = next(out) if len(wrap(tell)) == 1 else wrap(out)
         # clear every last thing
         self.clear()
         return out
     def first(self):
         '''first incoming thing'''
         with self._context():
-            return self._append(self._next(self._iterable))
+            return self._append(next(self._iterable))
 
     def last(self):
         '''last incoming thing'''
         with self._context():
-            i1, _ = self._split(self._iterable)
-            return self._append(self._deek(i1, maxlen=1).pop())
+            i1, _ = tee(self._iterable)
+            return self._append(deque(i1, maxlen=1).pop())
 
     def peek(self):
         '''results from read-only context'''
         out = self._wrapper(self._util)
-        return out[0] if self._len(out) == 1 else out
+        return out[0] if len(out) == 1 else out
 
     def results(self):
         '''yield outgoing things, clearing outgoing things as it iterates'''
         '''return outgoing things and clear outgoing things'''
         # return to default context
         self.unswap()
-        out, tell = self._split(self.outgoing)
+        out, tell = tee(self.outgoing)
         wrap = self._wrapper
-        out = self._next(out) if self._len(wrap(tell)) == 1 else wrap(out)
+        out = next(out) if len(wrap(tell)) == 1 else wrap(out)
         # clear outgoing things
         self.outclear()
         return out
 # -*- coding: utf-8 -*-
 '''twoq reducing mixins'''
 
+from math import fsum
 from heapq import merge
 from threading import local
-from itertools import cycle
+from functools import partial
 from collections import Iterable
+from operator import contains, truediv
+from itertools import cycle, tee, islice
 
-from twoq.support import isstring
+from twoq.support import Counter, isstring, imap, zip
 
 
 class MathMixin(local):
     @classmethod
     def _average(cls, iterable):
         '''average of `iterable`'''
-        i1, i2 = cls._split(iterable)
-        return cls._truediv(cls._sum(i1, 0.0), cls._len(cls._list(i2)))
+        i1, i2 = tee(iterable)
+        return truediv(sum(i1, 0.0), len(list(i2)))
 
     @classmethod
     def _median(cls, iterable):
         '''median of `iterable`'''
-        truediv_ = cls._truediv
-        i = cls._list(cls._sorted(iterable))
-        e = truediv_(cls._len(i) - 1, 2)
+        i = list(sorted(iterable))
+        e = truediv(len(i) - 1, 2)
         p = int(e)
-        return i[p] if e % 2 == 0 else truediv_(i[p] + i[p + 1], 2)
+        return i[p] if e % 2 == 0 else truediv(i[p] + i[p + 1], 2)
 
     def average(self):
         '''average of all incoming things'''
     def fsum(self):
         '''add incoming things together'''
         with self._context():
-            return self._append(self._fsum(self._iterable))
+            return self._append(fsum(self._iterable))
 
     def max(self):
         '''
         find maximum thing in incoming things, optionally using current
         call as key function
         '''
-        call_ = self._call
+        call = self._call
         with self._context():
-            if call_ is None:
-                return self._append(self._max(self._iterable))
-            return self._append(self._max(self._iterable, key=call_))
+            if call is None:
+                return self._append(max(self._iterable))
+            return self._append(max(self._iterable, key=call))
 
     def median(self):
         '''median of all incoming things'''
 
     def min(self):
         '''find minimum thing in incoming things using call as key function'''
-        call_ = self._call
+        call = self._call
         with self._context():
-            if call_ is None:
-                return self._append(self._min(self._iterable))
-            return self._append(self._min(self._iterable, key=call_))
+            if call is None:
+                return self._append(min(self._iterable))
+            return self._append(min(self._iterable, key=call))
 
     def minmax(self):
         '''minimum and maximum things among all incoming things'''
         with self._context():
-            i1, i2 = self._split(self._iterable)
-            return self._xtend(iter([self._min(i1), self._max(i2)]))
+            i1, i2 = tee(self._iterable)
+            return self._xtend(iter([min(i1), max(i2)]))
 
     def mode(self):
         '''mode of all incoming things'''
         with self._context():
             return self._append(
-                self._counter(self._iterable).most_common(1)[0][0]
+                Counter(self._iterable).most_common(1)[0][0]
             )
 
     def statrange(self):
         '''statistical range of all incoming things'''
         with self._context():
-            iterz = list(self._sorted(self._iterable))
+            iterz = list(sorted(self._iterable))
             return self._append(iterz[-1] - iterz[0])
 
     def sum(self, start=0):
         @param start: starting number (default: 0)
         '''
         with self._context():
-            return self._append(self._sum(self._iterable, start))
+            return self._append(sum(self._iterable, start))
 
 
 class TruthMixin(local):
     def all(self):
         '''if `all` incoming things are `True`'''
         with self._context():
-            return self._append(all(self._imap(self._call, self._iterable)))
+            return self._append(all(imap(self._call, self._iterable)))
 
     def any(self):
         '''if `any` incoming things are `True`'''
         with self._context():
-            return self._append(any(self._imap(self._call, self._iterable)))
+            return self._append(any(imap(self._call, self._iterable)))
 
     def contains(self, thing):
         '''
-        if `thing` is in incoming things
+        if `thing` is found in incoming things
 
         @param thing: some thing
         '''
         with self._context():
-            return self._append(self._contains(self._iterable, thing))
+            return self._append(contains(self._iterable, thing))
 
     def frequency(self):
         '''frequency of each incoming thing'''
         with self._context():
-            return self._append(self._counter(self._iterable).most_common())
+            return self._append(Counter(self._iterable).most_common())
 
     def quantify(self):
         '''how many times call is `True` for incoming things'''
         with self._context():
-            return self._append(self._sum(
-                self._imap(self._call, self._iterable)
-            ))
+            return self._append(sum(imap(self._call, self._iterable)))
 
     def uncommon(self):
         '''least common incoming thing'''
         with self._context():
             return self._append(
-                self._counter(self._iterable).most_common()[:-2:-1][0][0]
+                Counter(self._iterable).most_common()[:-2:-1][0][0]
             )
 
 
 
         @param iterable: an iterable
         '''
-        pending = len(cls._split(iterable, 1))
-        cycle_ = cycle
-        islice_, next_ = cls._islice, cls._next
-        nexts_ = cycle_(cls._partial(next_, iter(i)) for i in iterable)
+        islice_, next_, cycle_ = islice, next, cycle
+        nexts_ = cycle_(partial(next_, iter(i)) for i in iterable)
+        pending = len(tee(iterable, 1))
         while pending:
             try:
                 for nextz in nexts_:
     def pairwise(self):
         '''every two incoming things as a tuple'''
         with self._context():
-            a, b = self._split(self._iterable)
-            self._next(b, None)
-            return self._xtend(self._zip(a, b))
+            i1, i2 = tee(self._iterable)
+            next(i2, None)
+            return self._xtend(zip(i1, i2))
 
     def reduce(self, initial=None):
         '''
         '''
         with self._context():
             if initial is None:
-                return self._append(self._ireduce(self._call, self._iterable))
-            return self._append(self._ireduce(
-                self._call, self._iterable, initial,
-            ))
+                return self._append(reduce(self._call, self._iterable))
+            return self._append(reduce(self._call, self._iterable, initial))
 
     def reduce_right(self, initial=None):
         '''
 
         @param initial: initial thing (default: None)
         '''
-        call_ = self._call
+        call = self._call
         with self._context():
             if initial is None:
-                return self._append(self._ireduce(
-                    lambda x, y: call_(y, x), self._iterable,
+                return self._append(reduce(
+                    lambda x, y: call(y, x), self._iterable,
                 ))
-            return self._append(self._ireduce(
-                 lambda x, y: call_(y, x), self._iterable, initial,
+            return self._append(reduce(
+                 lambda x, y: call(y, x), self._iterable, initial,
             ))
 
     def roundrobin(self):
         position
         '''
         with self._context():
-            return self._xtend(self._zip(*self._iterable))
+            return self._xtend(zip(*self._iterable))
 
 
 class ReducingMixin(MathMixin, TruthMixin, ReduceMixin):