l.s.l.ITunableLoop(Interface) : interface documentation

Part of lp.services.looptuner View In Hierarchy

Interface for self-tuning loop bodies to be driven by LoopTuner.

To construct a self-tuning batched loop, define your loop body as a class implementing TunableLoop, and pass an instance to your LoopTuner.

Method isDone Is this loop finished?
Method __call__ Perform an iteration of the loop.
Method cleanUp Clean up any open resources.
def isDone():
Is this loop finished?

Once this returns True, the LoopTuner will no longer touch this object.

def __call__(chunk_size):
Perform an iteration of the loop.

The chunk_size parameter says (in some way you define) how much work the LoopTuner believes you should try to do in this iteration in order to get as close as possible to your time goal.

Note that chunk_size is a float, so, for example, if you use it to slice a list, be careful to round it to an int first.

def cleanUp(self):
Clean up any open resources.

Optional.

This method is needed because loops may be aborted before completion, so clean up code in the isDone() method may never be invoked.

API Documentation for Launchpad, generated by pydoctor at 2019-08-18 00:00:05.