Python Forum
Line by line execution of instructions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Line by line execution of instructions
#1
Can I force a program to execute instructions in the order they are written, line by line
Reply
#2
What do you mean? What you describe is how programs run unless they contain functions or loops. Do you want the program to pause between instructions?
Reply
#3
I am writing a program to run on a multi processor.. The ordering of. Of the statements is vitally important for the program to interact correctly with other programs. Is there a way to tell a Python compiler : do not change the order of instructions when compiling this program? Or maybe do not change the order of instructions starting at this point and ending at this other point when compiling this program. Handling loops ? inst1 Inst2 do n times inst3a inst3b end. inst4 inst5 Is executed as this sequence of instructions. inst1 inst2 inst3a inst3b ...... inst3a inst3b inst4 inst5 where the. inst3a inst3b Sequence is repeated n times
Reply
#4
The compiler does not change the order of instructions. "Compiling" in Python consists of converting the source code to bytecode that is run by the Python interpreter. There is no optimization stage that can change the order of the instructions. Loops remain loops. They are not flattened,

Python programs are single threaded unless they are explicitly written to be multi-threaded or use multiprocessing. You don't have to worry about the python interpreter taking your program and running it on multiple processors without your knowledge.

If you are doing multi-processing, there is no automatic mechanism for doing so. You have to write the code to create subprocesses. When using multiprocessing, there is no automatic method for synchronization. You have to write extra code to synchronize the processes. This can be fairly simple if you just need to wait for a subprocess to complete (start/join, await) but is more complicated when trying to synchronize two processes while running.

Could you provide more information about your particular concerns and what you are trying to do?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Line graph with two superimposed lines sawtooth500 4 386 Apr-02-2024, 08:56 PM
Last Post: sawtooth500
  How to add multi-line comment section? Winfried 1 241 Mar-24-2024, 04:34 PM
Last Post: deanhystad
  break print_format lengthy line akbarza 4 422 Mar-13-2024, 08:35 AM
Last Post: akbarza
  Reading and storing a line of output from pexpect child eagerissac 1 4,319 Feb-20-2024, 05:51 AM
Last Post: ayoshittu
  coma separator is printed on a new line for some reason tester_V 4 547 Feb-02-2024, 06:06 PM
Last Post: tester_V
  problem with spliting line in print akbarza 3 432 Jan-23-2024, 04:11 PM
Last Post: deanhystad
  Unable to understand the meaning of the line of code. jahuja73 0 329 Jan-23-2024, 05:09 AM
Last Post: jahuja73
  Receive Input on Same Line? johnywhy 8 809 Jan-16-2024, 03:45 AM
Last Post: johnywhy
  Reading in of line not working? garynewport 2 888 Sep-19-2023, 02:22 PM
Last Post: snippsat
  'answers 2' is not defined on line 27 0814uu 4 782 Sep-02-2023, 11:02 PM
Last Post: 0814uu

Forum Jump:

User Panel Messages

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