News for hackers. Stuff that matters.
Re:Async I/O for Python 3 by rdtsc on Tuesday March 19, 2013 @09:07AM (#5400596)
If it has generators it will make it easier. I remember being happy about finding out Twisted has inlineCallbacks. I basically let you not have to split your logical function into multiple functions simply because it has to to do some IO.

Before it used to be code like:

    def processShoppingCart(...):
       d.addCallback(_cb1)
       return d # (d is a Deferred)

   def _cb1(...):
      d2.addCallback(_cb2)
      return d2 # d2 is a another Deferred
etc.

Which with generators and inlineCallbacks turns into

    @someDecoratorThatEnableUsingInlineCallbacks
    def processShoppingCart(...):
       .. do some work ..
       yield <some_io_function_like_check_db>
       .. do some more work ..
       yield <some_io_other_io_function>
       ....
You get the idea. I am not too familiar with Node.js but I imagine it will help quite a bit.

There are no comments on this comment yet.