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 c
Sorin Schwimmer wrote:
> I am thinking on something in the following form:
>
>
> import time
> import thread
>
> delay=True
>
> def fn()
> global delay
> time.sleep()
> delay=False
>
> thread.start_new_thread(fn,())
>
> while delay:
>
>
> ...
if the loop calls out to python funct
"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
L
"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
| interrupti
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 8
Sorin Schwimmer wrote:
> I am thinking on something in the following form:
>
>
> import time
> import thread
>
> delay=True
>
> def fn()
> global delay
> time.sleep()
> delay=False
>
> thread.start_new_thread(fn,())
>
> while delay:
>
>
> ...
>
> while :
>
>
> ...
>
>
> Or,
I am thinking on something in the following form:
import time
import thread
delay=True
def fn()
global delay
time.sleep()
delay=False
thread.start_new_thread(fn,())
while delay:
...
while :
...
Or, if you need to use "break", the second loop may be
something like:
while T
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
> tim
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 "
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
> | >>
"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
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 ob
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:
>
>> 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
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 interrup
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
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
d
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
> 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:
> 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 optimi
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
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 the
22 matches
Mail list logo