Python Forum
Confused about python execution
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Confused about python execution
#1
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)
Reply


Messages In This Thread
Confused about python execution - by jpezz - Oct-07-2022, 04:02 PM
RE: Confused about python execution - by jpezz - Oct-09-2022, 03:54 PM
RE: Confused about python execution - by menator01 - Oct-09-2022, 04:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  kill python execution program lebossejames 0 328 Mar-16-2024, 11:16 AM
Last Post: lebossejames
  C++ programmer confused about why Python isn't working the way I intend Radical 2 868 Sep-15-2023, 04:21 AM
Last Post: Radical
  String int confused janeik 7 1,244 Aug-02-2023, 01:26 AM
Last Post: deanhystad
  I am confused with the key and value thing james1019 3 1,057 Feb-22-2023, 10:43 PM
Last Post: deanhystad
  Pandas confused DPaul 6 2,729 Sep-19-2021, 06:45 AM
Last Post: DPaul
  is and '==' i'm confused hshivaraj 6 2,848 Sep-15-2021, 09:45 AM
Last Post: snippsat
  Confused with 'flags' tester_V 10 5,162 Apr-12-2021, 03:03 AM
Last Post: tester_V
  Simple Tic Tac Toe but I'm confused Izith 1 2,326 Sep-26-2020, 04:42 PM
Last Post: Larz60+
  I am really confused with this error. Runar 3 3,188 Sep-14-2020, 09:27 AM
Last Post: buran
  How to to tie the execution of one process to another inside a loop in Python ignorant_wanderer 0 2,101 Jul-11-2020, 03:44 AM
Last Post: ignorant_wanderer

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020