Magic Optimisation

Paul McGuire ptmcg at
Mon Sep 5 16:27:41 CEST 2005

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

    def loop(self):
        self_pool_popleft = self.pool.popleft
        self_pool_append = self.pool.append
        self_call_exit_funcs = self.call_exit_funcs
        check = self.pool.__len__
        while check() > 0:
                while check() > 0:
                    task = self_pool_popleft()
            except StopIteration:

-- Paul

More information about the Python-list mailing list