Hi Ian,

    It depends on how they did the comparison. For in machine code you do a 
register to memory check or memory to memory check or register to register 
check. The clock cycles are more in moving memory or comparing memory because 
of the need to address the memory point. 
    It depends on how they wrote the comparison. It also depends on the order 
of checking and if memory had to be moved to do it and that to depends on the 
programmer and how they decided to do the logic for the check. 

Like assembler code:
  cmp [i],1
  jl move-on
  cmp [i],9
  jg move-on
  do something here
move-on:

  I used [] brackets to indicate the memory location of the i variable. Now in 
the other comparison I suspect that the way that check goes they had to either 
create a location for 1 or move i into a register and in either case more clock 
cycles needed to process the check.
    the first one above in my example is the faster check and mirrors the 
second comparison and would be standard machine code for the comparison. Now 
the other logic on how the stringing of comparisons is done, I suspect that the 
one of those check objects have to be moved into an area before the check in 
order to decode the logic...
    Thus the comparison in the first case below just requires lots more clock 
cycles to process it.

        Bruce


On 11/3/07, David Muffley <[EMAIL PROTECTED]> wrote:

  If I recall correctly, the syntax
  if 1 <= i <= 9
  runs slower than the syntax
  if i <= 9 and i >= 1
  Somewhere around 10% slower.  If you use psyco, it goes about 40% slower!

Do you know why?
Ian


Reply via email to