optimizing python for command-line piping