- Do comments affect the size of the executable file after compilation?
- Does the number of lines or characters affect the size of the executable file after compilation?
from time import sleeporimport time. Why
- oneComments do not affect. The number of lines can influence if you write very well Hindu code. - Vladimir Martyanov
- oneDecide what language you have a question? 3 point in general in a separate question is better to highlight. - insolor
- Equally for both interpreted and compiled languages? - Tanya
- @ Vladimir Martianov, but what does "well, very much Hindu code" look like? - Tanya
- @ Tanya Example - dedifferentiator
|
3 answers
- "After compilation" means the language of the type being compiled. In such languages, comments by definition (!) Do not fall into the executable file, they are discarded even at the stage of syntactic analysis.
- If we are talking about strictly the same program, but it can be assumed that the difference in the number of bytes of the source code can be formed when used, for example, in two copies of the code, variable names of different lengths. This difference does not affect the speed of execution. The second case is “stuck” a lot of spaces, for example (a + b ** c) / d instead of (a + b ** c) / d - The speed of the resulting code is not affected. The third case. Strictly one and the same program recorded - in the limit - "forest" or "in one line." (It may well take place in the same C ++). After compilation, they will all the same turn into the same code, i.e. There will be no difference in speed of execution. I stress once again - all this is true for compiled languages.
- This is already Python. The first option applies if you need only one of the entire set of package functions (in this case, sleep). The second is if you may need several package functions. The second option can also lead to name conflicts from different packages, i.e. be the source of a certain kind of error.
|
In C:
Not
No, if it is meant that the same text is divided into lines, for example, or the names of variables are made different. Obviously, a single-line program of the type of
puts("Hello");will be less than a program that solves some serious problem - in this case, the answer is Yes. Naturally, considering the executable file without debugging information.For C this question does not apply.
- Vladimir commented on the part of Python? - Tanya
|
- Python is an interpreted language. As far as I know, in C is not affected.
- If you change the number of lines or characters, then you change the way to solve the task, add or remove any actions, thereby you change the size of the executable file.
- I prefer
from time import sleep, because so on will have to write less. But if you write a lot, it is better to useimport time, because if you create your ownsleepfunction, they will not conflict, and if you usefrom time import sleep, then your function will be executed. In short, less likely to get confused.
from time import sleepon the one hand there are more characters thanimport time, but this way we use only one function from the module (library). And whenimport time- we call all the functions from the library, which means that it is most advantageous to usefrom time import sleep. I understand correctly ? Or does it depend not on the fact of importing the entire library, but on the number of functions used from the library? - Tanya- @Tanya, this topic pulls on a separate question, it is well written about the difference between
from module import functionandimport module. - tutaf
|