Optimize Pipeline by using a deque

This section of code is going to be pretty hot; it's best to optimize it as much as possible.

It might be worth it to switch to a list for the data variable as well, and use '\n'.join(data) (vs. string concatenation).

From [the docs](https://docs.python.org/2/library/collections.html#collections.deque):

"Though list objects support similar operations, they are optimized for fast fixed-length operations and incur O(n) memory movement costs for pop(0) and insert(0, v) operations which change both the size and position of the underlying data representation."