python/callback

Leandro Lucarella llucax at gmail.com
Fri Feb 15 16:35:01 CET 2008


malek at lcde.net, el 15 de febrero a las 13:21 me escribiste:
[snip]
> 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.

What about a best-of-both-worlds:
callback(watcher, revents, *arg, **kargs)?

:)

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
Did you know the originally a Danish guy invented the burglar-alarm
unfortunately, it got stolen




More information about the libev mailing list