"Paul McGuire" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Terry -
>
> If setting up a try-block is as fast (or "takes as long") as one
> iteration loop, then wont putting a try-block inside a loop double the
> execution time?
It will double (more or less) the loop overhead. T
Terry -
If setting up a try-block is as fast (or "takes as long") as one
iteration loop, then wont putting a try-block inside a loop double the
execution time?
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list
"ABO" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> There are other "optimisations" that could be applied that make this
> code faster but uglier. For example, putting another "while True: loop
> inside the try block to avoid the try block setup each iteration.
In CPython, 'setti
Bengt Richter wrote:
> On 5 Sep 2005 07:27:41 -0700, "Paul McGuire" <[EMAIL PROTECTED]> wrote:
>
> >I still think there are savings to be had by looping inside the
> >try-except block, which avoids many setup/teardown exception handling
> >steps. This is not so pretty in another way (repeated whil
Paul McGuire wrote:
> I still think there are savings to be had by looping inside the
> try-except block, which avoids many setup/teardown exception handling
> steps. This is not so pretty in another way (repeated while on
> check()), but I would be interested in your timings w.r.t. your current
On Mon, 05 Sep 2005 21:39:31 GMT, [EMAIL PROTECTED] (Bengt Richter) wrote:
>On 5 Sep 2005 07:27:41 -0700, "Paul McGuire" <[EMAIL PROTECTED]> wrote:
>
>>I still think there are savings to be had by looping inside the
>>try-except block, which avoids many setup/teardown exception handling
>>steps.
On 5 Sep 2005 07:27:41 -0700, "Paul McGuire" <[EMAIL PROTECTED]> wrote:
>I still think there are savings to be had by looping inside the
>try-except block, which avoids many setup/teardown exception handling
>steps. This is not so pretty in another way (repeated while on
>check()), but I would be
Raymond Hettinger posted this recipe to the Python Cookbook. I've not
tried it myself, but it sounds like what you're looking for.
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/277940
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list
I still think there are savings to be had by looping inside the
try-except block, which avoids many setup/teardown exception handling
steps. This is not so pretty in another way (repeated while on
check()), but I would be interested in your timings w.r.t. your current
code.
def loop(self):
Psyco actually slowed down the code dramatically.
I've fixed up the code (replaced the erroneous return statement) and
uploaded the code for people to examine:
The test code is here: http://metaplay.dyndns.org:82/~xerian/fibres.txt
These are the run times (in seconds) of the test file.
without p
> def loop(self):
> self_pool = self.pool
> self_call_exit_funcs = self.call_exit_funcs
> self_pool_popleft = self.pool.popleft
> self_pool_append = self.pool.append
> check = self.pool.__len__
> while check() > 0:
> task = self_pool_p
[EMAIL PROTECTED] writes:
> My use case involves < 1000 iterators, so psyco is not much help. It
> doesn't solve the magic creation of locals from instance vars either.
How about using __slots__ to put those instance vars at fixed offsets
in the pool object (self then needs to be a new-style class
Yes. It slows down the loop when there are only a few iterators in the
pool, and speeds it up when there are > 2000.
My use case involves < 1000 iterators, so psyco is not much help. It
doesn't solve the magic creation of locals from instance vars either.
Sw.
--
http://mail.python.org/mailman/l
I guess it is hard to see what the code is doing without a complete
example.
The StopIteration is actually raised by task.next(), at which point
task is removed from the list of generators (self.pool). So the
StopIteration can be raised at any time.
The specific optimisation I am after, which wil
[EMAIL PROTECTED] wrote:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/277940
For an even bigger improvement (in general), look at psyco:
http://psyco.sourceforge.net/.
Tim Delaney
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] writes:
> However, it is very ugly. Does anyone have any tips on how I could get
> this optimisation to occor magically, via a decorator perhaps?
Have you tried psyco?
--
http://mail.python.org/mailman/listinfo/python-list
This isn't much prettier, but what if you extract the try-except
overhead out from the while loop? You only expect the exception to
fire one time, at the end of the list. You can also eliminate any
localization of variables for calls that are not called in the loop,
such as self_pool (which does
Hello People.
I've have a very tight inner loop (in a game app, so every millisecond
counts) which I have optimised below:
def loop(self):
self_pool = self.pool
self_call_exit_funcs = self.call_exit_funcs
self_pool_popleft = self.pool.popleft
self_pool_append =
18 matches
Mail list logo