3.2.3 The profilers queue

Profilers can be chained. By calling several of the above profiling functions (or maybe the same function several times with different arguments), only the first one is started. The second one will only be started when the first one reaches one of its limits, and so on. For example:

import psyco

causes Psyco to compile everything until it takes 100 kilobytes of memory, and then only compile based on collected statistics. Remember that the limit of 100 kilobytes is largely underestimated by Psyco: your process' size will grow by much more than that before Psyco switches to profiling.

If all profilers reach their limits, profiling is stopped. Already-compiled functions will continue to run faster.

You may try to add a line "psyco.runonly()" after the last profiler, if all your profilers may stop (i.e. all of them have limits). It might help, or it might not. Feedback appreciated.

Note: Besides the limits, external events may prevent a specific profiler from running. When this occurs, Psyco falls back to the next profiler but may come back later when the external condition changes again. This occurs if some other program (e.g. the pdb debugger) sets a profiling or line-by-line tracing hook. Psyco always gracefully leaves the priority to other programs when they want to occupy Python's hooks.