Commits

Lynn Rees committed e88f99b Merge

automerge

Comments (0)

Files changed (47)

 34ebc8ed5a01c2127d3624920d062b31e9dcc628 0.4.8
 5439767de340107d4a8dda3f1529fd43a87da4a0 0.4.9
 b3dd7187e9ac3410aabd8868bb7152de64b5e70d 0.4.10
+72b79a8710a80858daa5193d788539b3be33380a 0.4.11
 
 setup(
     name='twoq',
-    version='0.4.11',
+    version='0.4.12',
     description='iterator chaining, underscored by a two-headed queue',
     long_description=open(join(getcwd(), 'README.rst'), 'r').read(),
     keywords='queue generator utility iterator functional programming',
 
 __all__ = ('twoq', 'manq', 'autoq', 'port')
 
-__version__ = (0, 4, 11)
+__version__ = (0, 4, 12)

twoq/active/filtering.py

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

twoq/active/mapping.py

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

twoq/active/mixins.py

 # -*- coding: utf-8 -*-
 '''active twoq mixins'''
 
+from collections import deque
 from contextlib import contextmanager
 
+from stuf.utils import clsname
+
 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 {}'
         ).format(
             self.__module__,
-            self._clsname(self),
+            clsname(self),
             self._INQ,
             list_(getr_(self._INQ)),
             self._WORKQ,
 
     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.queuing import SLOTS
 from twoq.ordering import RandomMixin, OrderingMixin, CombineMixin
 
 from twoq.active.mixins import AutoResultMixin, ManResultMixin
 
-###############################################################################
-## active random queues #######################################################
-###############################################################################
 
+class randomq(AutoResultMixin, RandomMixin):
 
-class arandomq(LookupsMixin, AutoResultMixin, RandomMixin):
+    '''auto-balanced randomizing queue'''
 
-    '''auto-balanced random queue'''
+    __slots__ = SLOTS
 
-randomq = arandomq
 
+class mrandomq(ManResultMixin, RandomMixin):
 
-class mrandomq(LookupsMixin, ManResultMixin, RandomMixin):
+    '''manually balanced randomizing queue'''
 
-    '''manually balanced random queue'''
+    __slots__ = SLOTS
 
-###############################################################################
-## active order queues #####EEE################################################
-###############################################################################
 
+class orderq(AutoResultMixin, OrderingMixin):
 
-class aorderq(LookupsMixin, AutoResultMixin, OrderingMixin):
+    '''auto-balanced ordering queue'''
 
-    '''auto-balanced order queue'''
+    __slots__ = SLOTS
 
-orderq = aorderq
 
-
-class morderq(LookupsMixin, ManResultMixin, OrderingMixin):
+class morderq(ManResultMixin, OrderingMixin):
 
     '''manually balanced order queue'''
 
+    __slots__ = SLOTS
 
-###############################################################################
-## active combination queues #####EEE##########################################
-###############################################################################
 
-
-class acombineq(LookupsMixin, AutoResultMixin, CombineMixin):
+class combineq(AutoResultMixin, CombineMixin):
 
     '''auto-balanced combination queue'''
 
-combineq = acombineq
+    __slots__ = SLOTS
 
 
-class mcombineq(LookupsMixin, ManResultMixin, CombineMixin):
+class mcombineq(ManResultMixin, CombineMixin):
 
     '''manually balanced combination queue'''
+
+    __slots__ = SLOTS

twoq/active/queuing.py

 # -*- coding: utf-8 -*-
 '''twoq active queues'''
 
-from twoq.imps import LookupsMixin
+from twoq.queuing import SLOTS
 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'''
 
+    __slots__ = SLOTS
 
-class manq(
-    LookupsMixin, ManResultMixin, FilterMixin, MapMixin, ReduceMixin,
-    OrderMixin,
-):
+
+class manq(ManResultMixin, FilterMixin, MapMixin, ReduceMixin, OrderMixin):
 
     '''manually balanced manipulation queue'''
 
+    __slots__ = SLOTS
+
 
 twoq = autoq

twoq/active/reducing.py

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

twoq/filtering.py

 
 from inspect import getmro
 from threading import local
+from functools import reduce
+from itertools import tee, islice
 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):
 
     '''collecting mixin'''
 
-    @staticmethod
-    def _members(iterable):
-        '''
-        collect members of things
-
-        @param thing: an iterable
-        '''
-        getattr_, AttributeError_ = getattr, AttributeError
-        for key in dir(iterable):
-            try:
-                thing = getattr_(iterable, key)
-            except AttributeError_:
-                pass
-            else:
-                yield key, thing
-
     @classmethod
-    def _walk(cls, truth, subcall, transform, iterable):
+    def _extract(cls, truth, subcall, transform, iterable):
         '''
         collect members of things
 
         @param truth: second "Truth" filter
         @param iterable: an iterable
         '''
-        getattr_, AttributeError_, walk_ = getattr, AttributeError, cls._walk
-        for key in cls._ifilter(truth, dir(iterable)):
-            try:
-                thing = getattr_(iterable, key)
-            except AttributeError_:
-                pass
-            else:
-                if subcall(thing):
-                    yield key, transform(
-                        walk_(truth, subcall, transform, thing)
-                    )
+        def members():
+            f, s, t, i = truth, subcall, transform, iterable
+            d, w, g, e = dir, cls._extract, getattr, AttributeError
+            test = lambda x: x.startswith('__') or x.startswith('mro')
+            for k in filterfalse(test, d(i)):
+                try:
+                    v = g(i, k)
+                except e:
+                    pass
                 else:
-                    yield key, thing
+                    if s(v):
+                        yield k, t(w(f, s, t, v))
+                    else:
+                        yield k, v
+        for member in ifilter(
+            truth, members(),
+        ):
+            yield member
 
     @classmethod
     def _mfilter(cls, call, iterable):
         @param call: "Truth" filter
         @param iterable: an iterable
         '''
-        for i in cls._ifilter(call, cls._members(iterable)):
+        def members(): #@IgnorePep8
+            itrbl, get_, AttributeError_ = iterable, getattr, AttributeError
+            test = lambda x: x.startswith('__') or x.startswith('mro')
+            for key in filterfalse(test, dir(iterable)):
+                try:
+                    thing = get_(itrbl, key)
+                except AttributeError_:
+                    pass
+                else:
+                    yield key, thing
+        for i in ifilter(call, members()):
             yield i
 
     @staticmethod
 
     def deepmembers(self):
         '''collect object members from incoming things and their bases'''
-        _mz = self._partial(self._mfilter, self._call)
-        if PY3:
-            def _memfilters(thing, mz=_mz, gc=getcls, ci=self._ichain):
-                t = lambda x: not x[0].startswith('mro')
-                return self._ifilter(
-                    t, ci(self._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]])))
+        _mf = self._mfilter
+        _mz = lambda x: _mf(self._call, x)
+        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):
+        '''extract object members from incoming things'''
+        with self._context():
+            walk_ = self._extract
+            call_, alt_, wrap_ = self._call, self._alt, self._wrapper
+            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,
-            )))
-            
-    def extract(self):
-        '''extract object members from incoming things'''
-        with self._context():
-            walk_ = self._walk
-            call_, alt_, wrap_ = self._call, self._altcall, self._wrapper
-            return self._xtend(self._ichain(self._imap(
-                lambda x: walk_(call_, alt_, wrap_, x), self._iterable,
+            mfilter, call = self._mfilter, self._call
+            return self._xtend(ichain(imap(
+                lambda x: mfilter(call, x), self._iterable,
             )))
 
     def pick(self, *names):
         @param key: determine uniqueness filter
         '''
         seen = set()
-        seen_add_, seen_contains_ = seen.add, seen.__contains__
-        if key is None:
-            for element in cls._filterfalse(seen_contains_, iterable):
-                seen_add_(element)
+        seen_add_ = seen.add
+        key_ = key
+        for element in iterable:
+            k = key_(element)
+            if k not in seen:
+                seen_add_(k)
                 yield element
-        else:
-            for element in iterable:
-                k = key(element)
-                if k not in seen:
-                    seen_add_(k)
-                    yield element
 
     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)
-    _iterz = lazier(iter)
-    _join = lazier(itertools.chain)
-    _len = lazier(len)
-    _list = lazier(list)
-    _max = lazier(max)
-    _methodcaller = lazier(methodcaller)
-    _min = lazier(min)
-    _next = lazier(next)
-    _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)
-    _sorted = lazier(sorted)
-    _split = lazier(itertools.tee)
-    _starmap = lazier(itertools.starmap)
-    _sum = lazier(sum)
-    _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.queuing import SLOTS
 from twoq.filtering import (
     FilteringMixin, CollectMixin, SetMixin, SliceMixin)
 
 from twoq.lazy.mixins import AutoResultMixin, ManResultMixin
 
-###############################################################################
-## lazy collecting queues ###################################################
-###############################################################################
 
-
-class acollectq(LookupsMixin, AutoResultMixin, CollectMixin):
+class collectq(AutoResultMixin, CollectMixin):
 
     '''auto-balanced collecting queue'''
 
-collectq = acollectq
+    __slots__ = SLOTS
 
 
-class mcollectq(LookupsMixin, ManResultMixin, CollectMixin):
+class mcollectq(ManResultMixin, CollectMixin):
 
     '''manually balanced collecting queue'''
 
-###############################################################################
-## lazy set queues ##########################################################
-###############################################################################
+    __slots__ = SLOTS
 
 
-class asetq(LookupsMixin, AutoResultMixin, SetMixin):
+class setq(AutoResultMixin, SetMixin):
 
     '''auto-balanced set queue'''
 
-setq = asetq
+    __slots__ = SLOTS
 
 
-class msetq(LookupsMixin, ManResultMixin, SetMixin):
+class msetq(ManResultMixin, SetMixin):
 
     '''manually balanced set queue'''
 
-###############################################################################
-## lazy slice queues ########################################################
-###############################################################################
+    __slots__ = SLOTS
 
 
-class asliceq(LookupsMixin, AutoResultMixin, SliceMixin):
+class sliceq(AutoResultMixin, SliceMixin):
 
     '''auto-balanced slice queue'''
 
-sliceq = asliceq
+    __slots__ = SLOTS
 
 
-class msliceq(LookupsMixin, ManResultMixin, SliceMixin):
+class msliceq(ManResultMixin, SliceMixin):
 
     '''manually balanced slice queue'''
 
-###############################################################################
-## lazy filter queues #######################################################
-###############################################################################
+    __slots__ = SLOTS
 
 
-class afilterq(LookupsMixin, AutoResultMixin, FilteringMixin):
+class filterq(AutoResultMixin, FilteringMixin):
 
     '''auto-balanced filter queue'''
 
-filterq = afilterq
+    __slots__ = SLOTS
 
 
-class mfilterq(LookupsMixin, ManResultMixin, FilteringMixin):
+class mfilterq(ManResultMixin, FilteringMixin):
 
     '''manually balanced filtering queue'''
+
+    __slots__ = SLOTS

twoq/lazy/mapping.py

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

twoq/lazy/mixins.py

 # -*- coding: utf-8 -*-
 '''lazy twoq mixins'''
 
+from itertools import tee, chain
 from contextlib import contextmanager
 
+from stuf.utils import clsname
+
 from twoq.queuing import ResultMixin, ThingsMixin
 
 __all__ = ('AutoQMixin', 'ManQMixin', 'AutoResultMixin', 'ManResultMixin')
     '''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: {}({}) => '
             'OUT: {}: ({})]) at {}>'
         ).format(
             self.__module__,
-            self._clsname(self),
+            clsname(self),
             self._INQ,
             list_(in2),
             self._WORKQ,
 
     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.queuing import SLOTS
 from twoq.ordering import RandomMixin, OrderingMixin, CombineMixin
 
 from twoq.lazy.mixins import AutoResultMixin, ManResultMixin
 
-###############################################################################
-## lazy random queues #######################################################
-###############################################################################
 
-
-class arandomq(LookupsMixin, AutoResultMixin, RandomMixin):
+class randomq(AutoResultMixin, RandomMixin):
 
     '''auto-balanced random queue'''
 
-randomq = arandomq
+    __slots__ = SLOTS
 
 
-class mrandomq(LookupsMixin, ManResultMixin, RandomMixin):
+class mrandomq(ManResultMixin, RandomMixin):
 
     '''manually balanced random queue'''
 
-###############################################################################
-## lazy order queues #####EEE################################################
-###############################################################################
+    __slots__ = SLOTS
 
 
-class aorderq(LookupsMixin, AutoResultMixin, OrderingMixin):
+class orderq(AutoResultMixin, OrderingMixin):
 
     '''auto-balanced order queue'''
 
-orderq = aorderq
+    __slots__ = SLOTS
 
 
-class morderq(LookupsMixin, ManResultMixin, OrderingMixin):
+class morderq(ManResultMixin, OrderingMixin):
 
     '''manually balanced order queue'''
 
+    __slots__ = SLOTS
 
-###############################################################################
-## active combination queues #####EEE##########################################
-###############################################################################
 
-
-class acombineq(LookupsMixin, AutoResultMixin, CombineMixin):
+class combineq(AutoResultMixin, CombineMixin):
 
     '''auto-balanced combination queue'''
 
-combineq = acombineq
+    __slots__ = SLOTS
 
 
-class mcombineq(LookupsMixin, ManResultMixin, CombineMixin):
+class mcombineq(ManResultMixin, CombineMixin):
 
     '''manually balanced combination queue'''
+
+    __slots__ = SLOTS

twoq/lazy/queuing.py

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

twoq/lazy/reducing.py

 # -*- coding: utf-8 -*-
 '''twoq lazy reducing queues'''
 
-from twoq.imps import LookupsMixin
+from twoq.queuing import SLOTS
 from twoq.reducing import MathMixin, TruthMixin, ReducingMixin
 
 from twoq.lazy.mixins import AutoResultMixin, ManResultMixin
 
-###############################################################################
-## lazy math queues ###########################################################
-###############################################################################
 
-
-class amathq(LookupsMixin, AutoResultMixin, MathMixin):
+class mathq(AutoResultMixin, MathMixin):
 
     '''auto-balancing math queue'''
 
-mathq = amathq
+    __slots__ = SLOTS
 
 
-class mmathq(LookupsMixin, ManResultMixin, MathMixin):
+class mmathq(ManResultMixin, MathMixin):
 
     '''manually balanced math queue'''
 
-###############################################################################
-## lazy truth queues ######E###################################################
-###############################################################################
+    __slots__ = SLOTS
 
 
-class atruthq(LookupsMixin, AutoResultMixin, TruthMixin):
+class truthq(AutoResultMixin, TruthMixin):
 
     '''auto-balancing truth queue'''
 
-truthq = atruthq
+    __slots__ = SLOTS
 
 
-class mtruthq(LookupsMixin, ManResultMixin, TruthMixin):
+class mtruthq(ManResultMixin, TruthMixin):
 
     '''manually balanced truth queue'''
 
+    __slots__ = SLOTS
 
-###############################################################################
-## lazy reduce queues #########################################################
-###############################################################################
 
-
-class areduceq(LookupsMixin, AutoResultMixin, ReducingMixin):
+class reduceq(AutoResultMixin, ReducingMixin):
 
     '''auto-balancing reduce queue'''
 
-reduceq = areduceq
+    __slots__ = SLOTS
 
 
-class mreduceq(LookupsMixin, ManResultMixin, ReducingMixin):
+class mreduceq(ManResultMixin, ReducingMixin):
 
     '''manually balanced reduce queue'''
+
+    __slots__ = SLOTS
 # -*- 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(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, key=call_))
 
 
 class CombineMixin(local):
 '''twoq queuing mixins'''
 
 from threading import local
+from collections import deque
+from itertools import tee, repeat
 from contextlib import contextmanager
 
+SLOTS = [
+    '_work', 'outgoing', '_util', 'incoming', '_call', '_alt', '_wrapper',
+    '_args', '_kw', '_clearout', '_context', '_CONFIG', '_INQ', '_WORKQ',
+    '_UTILQ', '_OUTQ', '_iterator',
+]
+
 
 class ThingsMixin(local):
 
         # current callable
         self._call = lambda x: x
         # current alt callable
-        self._altcall = lambda x: x
+        self._alt = lambda x: x
         # clear wrapper
-        self._wrapper = self._list
+        self._wrapper = list
         # reset postitional arguments
         self._args = ()
         # reset keyword arguments
         # set defaults
         self.unswap()
 
-    ###########################################################################
-    ## iteration ##############################################################
-    ###########################################################################
-
     @property
     def balanced(self):
         '''if queues are balanced'''
         return self.outcount() == self.__len__()
 
-    ###########################################################################
-    ## things clearance #######################################################
-    ###########################################################################
-
     def clear(self):
         '''clear every thing'''
-        return (
-            self.detap().unwrap().dealt().outclear().inclear()._wclear()
-            ._uclear()
-        )
+        self.detap().unwrap().dealt()
+        return self.outclear().inclear()._wclear()._uclear()
 
     ###########################################################################
     ## context rotation #######################################################
 
     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
         # set current callable
         self._call = call
         return self
-    
+
     def alt(self, call):
         '''
         set alternative current callable
 
         @param call: an alternative callable
         '''
-        self._altcall = call
+        self._alt = call
         return self
 
     def detap(self):
         # reset current callable (default is identity)
         self._call = lambda x: x
         return self
-    
+
     def dealt(self):
         '''clear current alternative callable'''
-        self._altcall = lambda x: x
+        self._alt = lambda x: x
         return self
 
     def factory(self, call):
         def wrap(*args, **kw):
             return call(*args, **kw)
         return self.tap(wrap)
-    
+
     defactory = detap
-    
+
     def wrap(self, wrapper):
         '''
         wrapper for outgoing things
         '''
         self._wrapper = wrapper
         return self
-    
+
     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'''
         '''
         with self.ctx1():
             return self._appendleft(thing)
-        
+
     appendleft = prepend
 
     ###########################################################################
         with self.ctx1():
             return self._xtend(things)
 
-    def preextend(self, things):
+    def prextend(self, things):
         '''
         extend left side of incoming things with `things`
 
         '''
         with self.ctx1():
             return self._xtendleft(things)
-        
-    extendleft = preextend
+
+    extendleft = prextend
 
     def outextend(self, 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:
                 pass
 
     @staticmethod
-    def iterexcept(call, exception, start=None):
+    def iterexcept(call, exception):
         '''
         call a function repeatedly until an exception is raised
 
         Raymond Hettinger, Python Cookbook recipe # 577155
         '''
         try:
-            if start is not None:
-                yield start()
             while 1:
                 yield call()
         except exception:
             pass
 
-    ###########################################################################
-    ## exhaustion iterators ###################################################
-    ###########################################################################
-
-    def exhaust(self, iterable, exception=StopIteration):
-        '''
-        call next on an iterator until it's exhausted
-
-        @param iterable: iterable to exhaust
-        @param exception: exception marking end of iteration
-        '''
-        next_ = self._next
-        try:
-            while 1:
-                next_(iterable)
-        except exception:
-            pass
-
-    def exhaustcall(self, call, iterable, exception=StopIteration):
-        '''
-        call function on an iterator until it's exhausted
-
-        @param call: call that does the exhausting
-        @param iterable: iterable to exhaust
-        @param exception: exception marking end of iteration
-        '''
-        next_ = self._next
-        iterable = self._imap(call, iterable)
-        try:
-            while True:
-                next_(iterable)
-        except exception:
-            pass
-        return self
-