3 ms·
If you're processing something one line at a time, and outputting something based on each line, then you don't need to read-and-process the entire file before p
by pyre 13y ago
If you're processing something one line at a time, and outputting something based on each line, then you don't need to read-and-process the entire file before printing everything out.
Other than that, it's more memory efficient.
- wfunction 13y agoThat's not "faster" (i.e. it doesn't take less time to run), it just has less delay from when it send back the first piece of output.
- pyre 13y agoAs part of a larger system, removing the delay can cause other parts of the system to do their processing in parallel. While this doesn't reduce the amount of time that it takes that piece of the pipeline to run, it will reduce the total runtime of the system. It can also be faster if you're searching for something in the file, because you can short-circuit reading the rest of the file when you find it.