There are two methods of execution compile and run where code is converted to machine code and then run. This is the fastest option used for C/C++, Fortran...
The second method is interpretive where each line is tokenized and the tokens are processed and run:
If your spaces were within quotes and were being printed each time then that would slow things down very very slightly. The more data you process the longer it takes a program to run.
However, in interpretive or compiled languages the spaces are removed from consideration as the code is converted to a more executable format.