Python Forum
Confused about python execution
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Confused about python execution
#3
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
Quote:#/usr/bin/python3
so 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.
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 294 Mar-16-2024, 11:16 AM
Last Post: lebossejames
  C++ programmer confused about why Python isn't working the way I intend Radical 2 819 Sep-15-2023, 04:21 AM
Last Post: Radical
  String int confused janeik 7 1,184 Aug-02-2023, 01:26 AM
Last Post: deanhystad
  I am confused with the key and value thing james1019 3 1,021 Feb-22-2023, 10:43 PM
Last Post: deanhystad
  Pandas confused DPaul 6 2,666 Sep-19-2021, 06:45 AM
Last Post: DPaul
  is and '==' i'm confused hshivaraj 6 2,801 Sep-15-2021, 09:45 AM
Last Post: snippsat
  Confused with 'flags' tester_V 10 5,061 Apr-12-2021, 03:03 AM
Last Post: tester_V
  Simple Tic Tac Toe but I'm confused Izith 1 2,272 Sep-26-2020, 04:42 PM
Last Post: Larz60+
  I am really confused with this error. Runar 3 3,095 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,079 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