Python Forum
Confused about python execution
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Confused about python execution
#5
(Oct-09-2022, 03:54 PM)jpezz Wrote: I see a notable difference in my program speeds when using ram disks for program execution and for storing output information
If your program does Input/Output, it will be faster if you read and write from RAM, but storing the program itself in RAM is not necessary, there is very little benefit. The program is always loaded to RAM when it is executed.
(Oct-09-2022, 03:54 PM)jpezz Wrote: Your example clearly shows the extra benefit of the pyc file
It does not. If the program runs during more than a few seconds, the difference is neglectible. Try with real programs and show the performance measurements.
(Oct-09-2022, 03:54 PM)jpezz Wrote: #/usr/bin/python3
The shebang line starts with #! , not # . It does not speed up anything.
(Oct-09-2022, 03:54 PM)jpezz Wrote: if the pyc file exists AND is newer AND I specify the py file, does python use the pyc
No, as far as I know. Python uses automatically the .pyc file when modules are imported for the first time. I don't think it does this for the main program.
(Oct-09-2022, 03:54 PM)jpezz Wrote: My guess is also that the only purposes of the shebang is to tell the executing program
This guess is wrong. In Linux (and Unixes in general), if the file has a shebang and it is executable, the OS uses the shebang to know which program to call (here python3).

Again, apart from Input/Output in RAM, which can be really useful, all these «optimizations» seem futile to me.
Larz60+ likes this post
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
RE: Confused about python execution - by Gribouillis - Oct-09-2022, 06:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  kill python execution program lebossejames 0 260 Mar-16-2024, 11:16 AM
Last Post: lebossejames
  C++ programmer confused about why Python isn't working the way I intend Radical 2 753 Sep-15-2023, 04:21 AM
Last Post: Radical
  String int confused janeik 7 1,103 Aug-02-2023, 01:26 AM
Last Post: deanhystad
  I am confused with the key and value thing james1019 3 990 Feb-22-2023, 10:43 PM
Last Post: deanhystad
  Pandas confused DPaul 6 2,616 Sep-19-2021, 06:45 AM
Last Post: DPaul
  is and '==' i'm confused hshivaraj 6 2,752 Sep-15-2021, 09:45 AM
Last Post: snippsat
  Confused with 'flags' tester_V 10 4,966 Apr-12-2021, 03:03 AM
Last Post: tester_V
  Simple Tic Tac Toe but I'm confused Izith 1 2,217 Sep-26-2020, 04:42 PM
Last Post: Larz60+
  I am really confused with this error. Runar 3 3,049 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,061 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