python/callback

malek at lcde.net malek at lcde.net
Fri Feb 15 13:21:39 CET 2008


Hi,

I'm implementing a python wrapper for libev, and I'd like people  
interested in having such an extension to help on a small design  
decision.

Watchers need a callback and, as I see it, we could define it in two  
different ways:

1/ we could require the callback to have the following signature:
def callback(watcher, revents)
In this case watcher would be the python watcher object, and revents a  
python int.
In fact, it would be almost like libev does it.

2/ or we could go a more "pythonic" way, and only require that the  
callback signature include revents as the first arg:
def callback(revents, *args, **kwargs)
args and kwargs could be provided at __init__ or by calling the  
set_callback method.

I implemented both to test, and there is not much difference between  
them in terms of speed or functionnality.
I'm tempted to follow the easy path and go the libev way.

Any comment/idea/critic/suggestion will be greatly appreciated.

malek



More information about the libev mailing list