q solution in kdb, runs in about 2.5s on my machine vs simple.py which takes 4.7s. Rough interpolation with the results table puts this on par with Rust/Go/OCaml or other compiled languages.
\t desc count each group `$lower " " vs raze read0 `:kjvbible_x10.txt
It's also 1 line!
I am sure q pros or k purists can optimize this even more...
EDIT: Moving the lower earlier brings this down to 1.9s
desc count each group `$ " " vs lower raze read0 `:kjvbible_x10.txt
I am sure q pros or k purists can optimize this even more...
EDIT: Moving the lower earlier brings this down to 1.9s