Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #57809

Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.

From Bernhard Schornak <schornak@web.de>
Newsgroups alt.comp.lang.borland-delphi, alt.comp.lang.c, alt.lang.asm, comp.lang.python
Subject Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.
Date 2013-10-28 11:49 +0100
Organization A noiseless patient Spider
Message-ID <l4lffa$o8p$1@dont-email.me> (permalink)
References <6f2b7$525f2302$5419b3e4$13466@cache1.tilbu1.nb.home.nl> <l48i1p$q38$1@dont-email.me> <774fd$526a559c$5419b3e4$11247@cache1.tilbu1.nb.home.nl>

Cross-posted to 4 groups.

Show all headers | View raw


Due to unknown "improvements", SeaMonkey's built-in news editor meanwhile ignores
saved changes and sends long deleted text parts rather than thwe last seen text -
"What you See Is _Not_ What You Get"...

This is the real reply to Skybuck's posting. Please ignore the mixture of deleted
text parts, older and newer text posted at 10:58 h.  Unfortunately, the option to
remove messages from the server became the victim of another "improvement", so it
is impossible for me to delete the other post.

Bernhard Schornak



Skybuck Flying wrote:


> Because it's logical.


What is logical?


> If the exit condition was placed on the top, the loop would exit immediatly.


This might be the programmer's intention?


> Instead the desired behaviour might be to execute the code inside the loop first and then exit.


With a 50 percent chance it might not. Are we fortune tellers who guess which one
might be true?


> Thus seperating logic into enter and exit conditions makes sense.


Let us assume a loop with variable iterations where the iteration count is passed
as function parameter. The code inside the loop body uses this iteration count as
index into an array and alters data in other arrays depending on computations and
set flags.

If we probed the loop's repeat condition at the end of the loop body per default,
we had to verify the passed iteration count before we enter the loop - otherwise,
the program crashed with erroneously passed negative numbers. We also had to sort
out zero. Otherwise, we started a count down through the full 32 or 64 bit range.
The last problem pops up, if the loop's repeat condition isn't met. In this case,
we had to restore all altered data before we could continue with the instructions
following the loop body.

Programming on machine language level grants us the freedom to create the fastest
possible code. It is no good idea to slow down our code just to obey questionable
"Universal Laws".


BTW: I placed label 0 at the wrong place. The proper loop should look like this:

func:...
      ...
    0:dec     rcx
      jbe     1f
      ...
      some
      code
      to
      perform
      ...
      jmp     0b

      p2align 5,,31
    1:continue
      with
      something
      else
      ...


Greetings from Augsburg

Bernhard Schornak

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Possibly better loop construct, also labels+goto important and on the fly compiler idea. "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2013-10-17 01:36 +0200
  Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2013-10-17 01:44 +0200
  Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Ben Finney <ben+python@benfinney.id.au> - 2013-10-17 10:47 +1100
  Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Steven D'Aprano <steve@pearwood.info> - 2013-10-17 09:06 +0000
  Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-17 16:53 -0700
    Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Skip Montanaro <skip.montanaro@gmail.com> - 2013-10-17 19:39 -0500
    Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-17 17:41 -0700
    Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-18 08:40 +0100
    Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Chris Angelico <rosuav@gmail.com> - 2013-10-18 18:44 +1100
    Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-18 09:11 +0100
      Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-21 14:19 -0700
        Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Dave Angel <davea@davea.name> - 2013-10-22 03:34 +0000
  Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-17 17:43 -0700
    Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-18 08:42 +0100
  Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-21 22:35 +0100
  Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Bernhard Schornak <schornak@web.de> - 2013-10-23 15:13 +0200
    Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2013-10-24 22:02 +0200
      Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-25 15:13 +0100
      Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Bernhard Schornak <schornak@web.de> - 2013-10-28 10:58 +0100
      Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Bernhard Schornak <schornak@web.de> - 2013-10-28 11:49 +0100
        Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2013-10-29 12:37 +0100
          Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-29 14:08 +0000
            Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. rurpy@yahoo.com - 2013-10-29 13:00 -0700
              Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Steven D'Aprano <steve@pearwood.info> - 2013-10-30 10:22 +0000
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. rurpy@yahoo.com - 2013-10-30 19:48 -0700
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Steven D'Aprano <steve@pearwood.info> - 2013-10-31 08:41 +0000
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. rurpy@yahoo.com - 2013-10-31 21:41 -0700
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-01 05:41 +0000
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. rurpy@yahoo.com - 2013-11-01 18:50 -0700
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-02 03:52 +0000
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. rurpy@yahoo.com - 2013-11-03 09:46 -0800
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Joshua Landau <joshua@landau.ws> - 2013-11-02 18:22 +0000
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-03 05:17 +0000
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-03 10:45 +0100
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. rurpy@yahoo.com - 2013-11-03 09:50 -0800
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-03 19:49 +0100
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Ben Finney <ben+python@benfinney.id.au> - 2013-11-04 09:11 +1100
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-04 09:38 +0100
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Ben Finney <ben+python@benfinney.id.au> - 2013-11-04 20:07 +1100
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-04 10:38 +0100
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-02 18:36 +0000
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-01 13:50 +0100
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. rurpy@yahoo.com - 2013-11-01 18:51 -0700
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-02 12:15 +0100
          Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Bernhard Schornak <schornak@web.de> - 2013-11-01 00:53 +0100
            Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2013-11-02 20:49 +0100
              Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Chris Angelico <rosuav@gmail.com> - 2013-11-03 15:17 +1100
        Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. "wolfgang kern" <nowhere@never.at> - 2013-10-29 19:08 +0100
          Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Bernhard Schornak <schornak@web.de> - 2013-11-01 00:44 +0100
  Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-25 11:57 -0700
    Don't use default Google Group client (was re:....) Terry Reedy <tjreedy@udel.edu> - 2013-10-25 16:05 -0400
      Re: Don't use default Google Group client (was re:....) rurpy@yahoo.com - 2013-10-25 16:44 -0700
        Re: Don't use default Google Group client (was re:....) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-26 01:19 +0100
          Re: Don't use default Google Group client (was re:....) rurpy@yahoo.com - 2013-10-26 07:58 -0700
            Re: Don't use default Google Group client (was re:....) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-26 16:38 +0100
              Re: Don't use default Google Group client (was re:....) rurpy@yahoo.com - 2013-10-26 21:36 -0700
        Re: Don't use default Google Group client (was re:....) Chris Angelico <rosuav@gmail.com> - 2013-10-26 11:25 +1100
          Re: Don't use default Google Group client (was re:....) rurpy@yahoo.com - 2013-10-26 07:55 -0700
        Re: Don't use default Google Group client (was re:....) Terry Reedy <tjreedy@udel.edu> - 2013-10-25 20:35 -0400
          Re: Don't use default Google Group client (was re:....) rurpy@yahoo.com - 2013-10-26 08:00 -0700
        Re: Don't use default Google Group client (was re:....) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-26 02:40 +0000
          Re: Don't use default Google Group client (was re:....) rusi <rustompmody@gmail.com> - 2013-10-26 05:15 -0700
            Re: Don't use default Google Group client Ben Finney <ben+python@benfinney.id.au> - 2013-10-27 00:02 +1100
            Re: Don't use default Google Group client (was re:....) rurpy@yahoo.com - 2013-10-26 08:07 -0700
            Re: Don't use default Google Group client (was re:....) Chris Angelico <rosuav@gmail.com> - 2013-10-27 00:25 +1100
              Re: Don't use default Google Group client (was re:....) rurpy@yahoo.com - 2013-10-26 21:43 -0700
          Re: Don't use default Google Group client (was re:....) rurpy@yahoo.com - 2013-10-26 08:05 -0700
            Re: Don't use default Google Group client (was re:....) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-26 17:24 +0000
              Re: Don't use default Google Group client (was re:....) rurpy@yahoo.com - 2013-10-26 21:33 -0700
            Re: Don't use default Google Group client (was re:....) Chris Angelico <rosuav@gmail.com> - 2013-10-27 09:15 +1100
              Re: Don't use default Google Group client (was re:....) rurpy@yahoo.com - 2013-10-26 21:45 -0700
          Re: Don't use default Google Group client (was re:....) Grant Edwards <invalid@invalid.invalid> - 2013-10-28 14:23 +0000
    Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. "Rhodri James" <rhodri@wildebst.demon.co.uk> - 2013-10-25 22:09 +0100
  Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-26 13:37 -0700
    Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. rusi <rustompmody@gmail.com> - 2013-10-26 18:45 -0700
      Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Chris Angelico <rosuav@gmail.com> - 2013-10-27 12:56 +1100
        Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. rurpy@yahoo.com - 2013-10-27 22:29 -0700
      Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. rurpy@yahoo.com - 2013-10-26 22:04 -0700
        Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. rusi <rustompmody@gmail.com> - 2013-10-27 00:59 -0700
          Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. rurpy@yahoo.com - 2013-10-27 22:40 -0700
            Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. rusi <rustompmody@gmail.com> - 2013-10-27 22:56 -0700
              Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. rusi <rustompmody@gmail.com> - 2013-10-27 23:51 -0700
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. rurpy@yahoo.com - 2013-10-28 21:03 -0700
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Chris Angelico <rosuav@gmail.com> - 2013-10-29 17:22 +1100
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. rurpy@yahoo.com - 2013-10-30 19:53 -0700
                OT: Hierarchies [was Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-01 07:00 +0000
                Re: OT: Hierarchies [was Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.] Chris Angelico <rosuav@gmail.com> - 2013-11-01 19:19 +1100
                Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-10-29 08:45 -0400
      Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-10-27 12:10 -0400
    Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. rusi <rustompmody@gmail.com> - 2013-10-27 03:53 -0700
  Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-26 19:02 -0700
  Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea. Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-11-02 12:40 -0700

csiph-web