pytoolz/toolz — pull request #178 by eriknw (2014-05-10 13:15:23+00:00)
Title: Faster unique, isdistinct, merge_sorted, and sliding_window.

The `key` keyword argument to `unique` was changed from `identity` to `None`. This better matches API elsewhere, and lets us remove `identity` from being redefined in `itertoolz`, which always seemed a little weird.

Most of the speed improvements come from avoiding attribute resolution in frequently run code. Attribute resolution (i.e., the "dot" operator) is probably more costly than one would expect. Fortunately, there weren't many places to apply this optimization, so impact on code readability was minimal.

`unique` employs another optimization: branching by `key is None` outside the loop (thus requiring two loops). While this violates the DRY principle (and, hence, I would prefer not to do it in general), this is only a few lines of code that remain side-by-side, and the performance increase is worth it.

`merge_sorted` is now optimized when only a single iterable remains. This makes it *so* much faster while in this condition.