Answer the question
In order to leave comments, you need to log in
Does the number of lines of code affect the speed of program execution?
The question is about Python, it is primarily of interest, but it is interesting to hear about other programming languages ​​as well. It’s just that for some reason they don’t write about this at all in textbooks, although the question is obvious and suggests itself. It is generally important for a computer how many lines we will scatter our code? Or does he care?
I understand that most often the readability of the code will always come first, but let's say we are considering an example when you write code for yourself and you can write the entire code at least in one line, or you can scatter it over 100 lines.
Answer the question
In order to leave comments, you need to log in
The number of rows does not affect - affects the number of operations.
The program has critical and not so critical moments.
Critical for speed optimize as much as possible, non-critical - no
It is generally important for a computer how many lines we will scatter our code?
Certainly! If you have a source file with one file per 10GB, it will run slowly, slowly. Well, not every compiler will cope with the Hindu code-sheet - it can turn out to be much slower.
As already mentioned, it is not the number of rows that affects, but the operations.
I add:
Strings can be different
l = [[0 for _ in range(100)] for _ in range(100)]
x = 1 + 1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question