Hi friends of VIFF,
I've implemented Share and ShareList in C, based on a C implementation
of Deferred. Using the C extension, benchmark.py and aes.py show a speed
up between 50 and 100 percent.
The code is in my repository: http://hg.viff.dk/mkeller
To use the extension, first compile and install it:
$ python setup.py install [--prefix PREFIX]
Then, add the following lines two to your program before importing
anything from viff or twisted:
If the parameter is True, the VIFF reactor is also installed, so this
doesn't have to be done separately.
There is a notable difference to the standard implementation of
Deferred: Errbacks are disabled and exceptions raised in callbacks are
not caught. This is for the following reasons:
- The implementation was inefficient (too many isinstance() calls).
- Errbacks are only used for error reporting in VIFF. However, I prefer
VIFF to crash (and print a traceback) immediately if there is an
exception instead of wrapping the exception and reporting it later,
which makes debugging harder.
I'm open for comments on this issue. It shouldn't be hard to reimplement
errbacks or to implement something different like a global errback. For
compatibility, all Deferred methods are still present.
If trial is modified to load the C extension, all tests succeed except a
viff-devel mailing list (http://viff.dk/)