I copy my programs to a directory that is a ram disk (for speed). Note that execution speed is critical. Startup time is not.
cp ~key/Programs.Source/py3*.py ~key/Programs # Copy to RAM disk
Then I execute:
python3 -m compileall ~key/Programs/py3*
This creates the subdirectory __pycache__ and the .pyc files
Now, presently, I execute my programs by having in the bash script:
python3 Programs/[xxx.py]
Is this the fastest way for them to execute or should I be executing them as
python3 Programs/__pycache__/[xxx.pyc]
or simply
Programs/__pycache__[/xxx.pyc]
It was my understanding that if the subdirectory __pycache_ existed, it would automatically use the program name there but I am not too sure any more.
My objective is to have them execute as quickly as possible.
Also, at the time I originally built the programs, I did not use
#/usr/bin/python3
because I built them with python2 knowing I would eventually go over to python3. I never got around to adding in that line.
Is there any significant difference in time to use that line and do this:
Programs/[xxx.py]
instead of this
#/usr/bin/python3 Programs/[xxx.py]
or is it just good practice so as to identify that this is a Python3 script vs any other type and that the shell knows to call /usr/bin/python3 to run it? Even 40 years ago, I knew to use the #!/bin/sh header but didn't do it for my python programs.
(Note, there was no bash - only sh and csh back in those days)
cp ~key/Programs.Source/py3*.py ~key/Programs # Copy to RAM disk
Then I execute:
python3 -m compileall ~key/Programs/py3*
This creates the subdirectory __pycache__ and the .pyc files
Now, presently, I execute my programs by having in the bash script:
python3 Programs/[xxx.py]
Is this the fastest way for them to execute or should I be executing them as
python3 Programs/__pycache__/[xxx.pyc]
or simply
Programs/__pycache__[/xxx.pyc]
It was my understanding that if the subdirectory __pycache_ existed, it would automatically use the program name there but I am not too sure any more.
My objective is to have them execute as quickly as possible.
Also, at the time I originally built the programs, I did not use
#/usr/bin/python3
because I built them with python2 knowing I would eventually go over to python3. I never got around to adding in that line.
Is there any significant difference in time to use that line and do this:
Programs/[xxx.py]
instead of this
#/usr/bin/python3 Programs/[xxx.py]
or is it just good practice so as to identify that this is a Python3 script vs any other type and that the shell knows to call /usr/bin/python3 to run it? Even 40 years ago, I knew to use the #!/bin/sh header but didn't do it for my python programs.
(Note, there was no bash - only sh and csh back in those days)