Oct-09-2022, 03:54 PM
Thanks for your reply. I see a notable difference in my program speeds when using ram disks for program execution and for storing output information (which is copied to the real disk periodically) but that's not the real subject of my question.
Using your example, it appears that executing
python3 paillasse/pf/pyspam.py
is notably slower than
python3 paillasse/pf/__pycache__/pyspam.cpython-310.pyc
but it is not clear that in the first example that you created the pyc file before the first example. To clarify my question, if the pyc file exists AND is newer AND I specify the py file, does python use the pyc such that the two commands take the same time and it uses the pyc automatically meaning I don't have to explicitly use it in the command line or should I be using the pyc file by name as shown in the second example? Your example clearly shows the extra benefit of the pyc file but it is not clear as to whether it existed prior to running the py file or whether you created it between those two examples.
I am also curious as to whether using the use of the
My guess is that pre-compiling and creating the pyc file removes all the comment lines (I have LOTS of them mostly to help me remember what and why I was doing when I wrote each line of the code), merging the includes into the code and doing the interpretation ahead of time to increase the execution speed and reduce the loading time.
My guess is also that the only purposes of the shebang is to tell the executing program (i.e. python, python2, python3) and the person running it that code being executed is indeed really intended for that compiler.
Using your example, it appears that executing
python3 paillasse/pf/pyspam.py
is notably slower than
python3 paillasse/pf/__pycache__/pyspam.cpython-310.pyc
but it is not clear that in the first example that you created the pyc file before the first example. To clarify my question, if the pyc file exists AND is newer AND I specify the py file, does python use the pyc such that the two commands take the same time and it uses the pyc automatically meaning I don't have to explicitly use it in the command line or should I be using the pyc file by name as shown in the second example? Your example clearly shows the extra benefit of the pyc file but it is not clear as to whether it existed prior to running the py file or whether you created it between those two examples.
I am also curious as to whether using the use of the
Quote:#/usr/bin/python3so as to directly call the program speeds anything up vs having to specify
Quote: python3 program.py.
My guess is that pre-compiling and creating the pyc file removes all the comment lines (I have LOTS of them mostly to help me remember what and why I was doing when I wrote each line of the code), merging the includes into the code and doing the interpretation ahead of time to increase the execution speed and reduce the loading time.
My guess is also that the only purposes of the shebang is to tell the executing program (i.e. python, python2, python3) and the person running it that code being executed is indeed really intended for that compiler.