[Python-ideas] Async API: some code to review

Steve Dower Steve.Dower at microsoft.com
Thu Nov 1 19:07:56 CET 2012

Terry Reedy wrote:
> On 11/1/2012 12:44 PM, Steve Dower wrote:
>>>> C# and VB use
>>>> their async/await keywords (good 8 min intro video on those:
>>>> http://www.visualstudiolaunch.com/vs2012vle/Theater?sid=1778
> [SNIP]
> Actually, I do not see how just adding 4 keywords would necessarily have 
> the effect it did. I imagine there is a bit more to the story than was shown,
> like the 'original' code being carefully written so that the change would
> have the effect it did. The video is, after all, an advertorial. Nonetheless,
> it was impressive.

It is certainly a dramatic demo, and you are right to be skeptical. The "carefully written" part is that the code already used paging as part of its query - the "give me movies from 1950" request is actually a series of "give me 10 movies from 1950 starting from {0, 10, 20, 30, ...}" requests (this is why you see the progress counter go up by 10 each time) - and it's already updating the UI between each page. The "4 keywords" also activate a significant amount of compiler machinery that actually rewrites the original code, much like the conversion to a generator, so there is quite a bit of magic.

There are plenty of videos at http://channel9.msdn.com/search?term=async+await that go much deeper into how it all works, including the 3rd-party extensibility mechanisms. 

(And apologies about the video only being available with Silverlight - I didn't realise this when I originally posted it. The videos at the later link are much more readily available, but also very deeply technical and quite long.)


More information about the Python-ideas mailing list