Events in Python

S

Simon Pickles

Hi,

I have a stackless python app, using twisted in parts (.internet and
..adbapi).

I need a little help getting pythonic after years of c++ hell.

I'd like to use a system of events and observers, like c++ boost.signal.

I'd like to be able to subscribe multiple callbacks to a single function
and cal them all using something like:

event.invoke("some data to send with invocation")

I'm thinking twisted callbacks do this:

def observe(self, f);
self.event.addcallback(f)

Are there other ways?

Thanks

Si
 
I

Ivan Illarionov

Compared to what, did you measure something?

As example, instantiation of Model classes in Django (Model.__init__)
sends two signals (pre_init and post_init) - they are rarely used in
practice - but they make instantiation about two times slower. Yes, I
measured that.

The creator of Louie (Patrick K. O'Brien) himself seems to use them
only as an option that can be enabled/disabled in his projects (e.g.
Schevo) - because they are slow.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top