I was just looking at asq's documentation. Very nice work! I just
wanted to mention that there are functions in the operator module that
do the same things as the k_, a_, and m_ functions, only they are
implemented in C and will avoid some of the Python function call
overhead of the lambda implementation. Specifically, k_ == itemgetter,
a_ == attrgetter, m_ == methodcaller. itemgetter and attrgetter have
the additional feature of allowing one to chain the keys/attributes;
e.g. attrgetter('x', 'y')(z) == z.x.y.
Similarly, most of the comparison functions in in predicate.py could
be replaced with mildly creative use of functools.partial() and the
comparison functions in operator. E.g.
def lt_(rhs):
return functools.partial(operator.gt, rhs)
http://docs.python.org/library/operator
http://docs.python.org/library/functools#functools.partial
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco