Claudio Grondi [EMAIL PROTECTED] wrote:
8-
| The test of the counter is what actually slows the loop down. Probably
| the test of time slows the loop even more down. Any test slows a loop
| down, so the idea here is to get rid of the test what can be done by
| interrupting
Hendrik van Rooyen [EMAIL PROTECTED] wrote:
8-
Here are some more results, three runs without, and three with a comment in the
body of the interesting loop:
(a summary follows the detail)
python junk.py
0x501
Loop 1 Elapsed time is: 31.2168951035
Loop 1
Sorin Schwimmer wrote:
I am thinking on something in the following form:
code
import time
import thread
delay=True
def fn()
global delay
time.sleep(your_amount_of_time_in_seconds)
delay=False
thread.start_new_thread(fn,())
while delay:
statement 1
statement 2
...
Claudio Grondi wrote:
Sometimes it is known in advance, that the time spent in a loop will be
in order of minutes or even hours, so it makes sense to optimize each
element in the loop to make it run faster.
One of instructions which can sure be optimized away is the check for
the break
Claudio Grondi [EMAIL PROTECTED] Wrote:
| Fredrik Lundh wrote:
| Diez B. Roggisch wrote:
|
| A while loop has a condition. period. The only thing to change that is
| to introduce a uncoditioned loop, and use self-modifying code to make
| it a while-loop after that timer interrupt of yours.
Hendrik van Rooyen wrote:
Claudio Grondi [EMAIL PROTECTED] Wrote:
| Fredrik Lundh wrote:
| Diez B. Roggisch wrote:
|
| A while loop has a condition. period. The only thing to change that is
| to introduce a uncoditioned loop, and use self-modifying code to make
| it a while-loop
to Fredrik Lundh
I'm afraid Claudio Grondi can't use your solution, as
he needs it hosted on Windows, which lacks
signal.alarm.
to Claudio Grondi
How about splitting your loop in two? The first loop
would check for your boolean, which is changed by your
timer, the second loop will check for your
Sorin Schwimmer wrote:
to Fredrik Lundh
I'm afraid Claudio Grondi can't use your solution, as
he needs it hosted on Windows, which lacks
signal.alarm.
to Claudio Grondi
How about splitting your loop in two? The first loop
would check for your boolean, which is changed by your
timer, the
I am thinking on something in the following form:
code
import time
import thread
delay=True
def fn()
global delay
time.sleep(your_amount_of_time_in_seconds)
delay=False
thread.start_new_thread(fn,())
while delay:
statement 1
statement 2
...
while other_condition:
statement 1
Sorin Schwimmer wrote:
I am thinking on something in the following form:
code
import time
import thread
delay=True
def fn()
global delay
time.sleep(your_amount_of_time_in_seconds)
delay=False
thread.start_new_thread(fn,())
while delay:
statement 1
statement 2
...
Claudio Grondi wrote:
Sorin Schwimmer wrote:
[...]
It doesn't.
Claudio
Sometimes silence is preferable to a concrete response. It takes less
time and occupies less bandwidth.
regards
Steve
who should perhaps have followed his own advice
--
Steve Holden +44 150 684 7255 +1 800
Sometimes it is known in advance, that the time spent in a loop will be
in order of minutes or even hours, so it makes sense to optimize each
element in the loop to make it run faster.
One of instructions which can sure be optimized away is the check for
the break condition, at least within
Claudio Grondi schrieb:
Sometimes it is known in advance, that the time spent in a loop will be
in order of minutes or even hours, so it makes sense to optimize each
element in the loop to make it run faster.
One of instructions which can sure be optimized away is the check for
the break
Diez B. Roggisch wrote:
Claudio Grondi schrieb:
Sometimes it is known in advance, that the time spent in a loop will
be in order of minutes or even hours, so it makes sense to optimize
each element in the loop to make it run faster.
One of instructions which can sure be optimized away is
The idea is to speed up a loop by using a timer interrupt interfering
with the loop, so that only after the timer interrupt would occur, the
loop will start to check its break condition in each iteration.
No checking of any kind in the loop should happen up to that time to
minimize the
Diez B. Roggisch wrote:
The idea is to speed up a loop by using a timer interrupt interfering
with the loop, so that only after the timer interrupt would occur, the
loop will start to check its break condition in each iteration.
No checking of any kind in the loop should happen up to that
Diez B. Roggisch wrote:
A while loop has a condition. period. The only thing to change that is
to introduce a uncoditioned loop, and use self-modifying code to make it
a while-loop after that timer interrupt of yours.
or use a timer interrupt to interrupt the loop:
import signal, time
def
Diez B. Roggisch wrote:
The idea is to speed up a loop by using a timer interrupt interfering
with the loop, so that only after the timer interrupt would occur, the
loop will start to check its break condition in each iteration.
No checking of any kind in the loop should happen up to that
Fredrik Lundh wrote:
Diez B. Roggisch wrote:
A while loop has a condition. period. The only thing to change that is
to introduce a uncoditioned loop, and use self-modifying code to make
it a while-loop after that timer interrupt of yours.
or use a timer interrupt to interrupt the
Fredrik Lundh schrieb:
Diez B. Roggisch wrote:
A while loop has a condition. period. The only thing to change that is
to introduce a uncoditioned loop, and use self-modifying code to make
it a while-loop after that timer interrupt of yours.
or use a timer interrupt to interrupt the
Diez B. Roggisch wrote:
No doubt that changing the flag asynchronously is a gain by delegating
the timing code to the OS. Yet the while loop still has a condition -
you could as well set a flag in the signal handler an do it like this:
if the OP is obsessed with performance, why are you
Fredrik Lundh schrieb:
Diez B. Roggisch wrote:
No doubt that changing the flag asynchronously is a gain by delegating
the timing code to the OS. Yet the while loop still has a condition -
you could as well set a flag in the signal handler an do it like this:
if the OP is obsessed
22 matches
Mail list logo