Re:When your data doesn’t fit in memory: the basic techniques
by xondono on Tuesday November 12, 2019 @03:41AM
(#21512565)
Not an expert, but after reading around OP is saying you only need a constant sized buffer (that could be as little as a character deep) to read the whole file looking for line breaks. This roughly takes O(1) space (A lot of commenters are confusing time vs space requirements) but there's a little nitpick to be found, in extremely big files the line counter itself would be O(log(n)) and would dominate.
Can you elaborate on the O(1) solution?