[Twisted-Python] Consensus on speed of deferred call/errback-style execution?
exarkun at divmod.com
Fri Oct 24 11:41:21 EDT 2008
On Fri, 24 Oct 2008 17:25:29 +0200, Terry Jones <terry at jon.es> wrote:
>Last year someone mentioned to me that using defer.inlineCallbacks (versus
>writing a bunch of independent standalone callback functions) incurs some
>sort of (significant) speed penalty during execution.
>How accurate is that?
>Very briefly, you can add a bunch of callbacks to a deferred in multiple
> 1. A bunch of top-level functions
> 2. A top-level function that nests callbacks that nest callbacks...
> 3. A bunch of top-level class methods
> 4. A top-level class method that nests callbacks...
>This is deliberately simplistic, and all the above can of course also be
>I wrote a little timing code to play with this (via timing a function that
>uses inlineCallbacks that yields a single passed deferred) but decided to
>ask here before going much further as there are lots of different avenues
>that could be explored.
A suite of benchmarks for Deferred has been on my to-do list for a long
time. Aside from knowing which usage patterns are more efficient, this
needs to be part of our testing process so we can evaluate optimization
of Deferred and be aware of performance regressions we might introduce.
I don't know if anyone else has done this already, but if you end up
writing something, it'd be great if it were in a form which could be
run automatically as part of our build process.
More information about the Twisted-Python