I usually write those file summing programs to take advantage of the
fact readDouble (et al) return the tail of the file. Saves a lot of
different checks:
import qualified Data.ByteString.Char8 as S
import qualified Data.ByteString.Unsafe as S
import Data.ByteString.Lex.Double
main = print . go 0 =<< S.getContents
where
go !n s = case readDouble s of
Nothing -> n
Just (k,rest) -> go (n+k) (S.tail rest)
should run pretty well (ghc -O2 --make). Note how we sum as we go.
Now, for yours, you'll want to avoid building up all those
intermediate structures (which i'm imagining you aren't doing in the
python case).