alex-sherman / deco

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

using futures.ascompleted construct

aliabbasjp opened this issue · comments

How is it possible to process the results like the futures.ascompleted construct , so as soon as the result is available it can be processed?

Instead of doing function decoration cant we do at lower granularity and mark the section of code rather then delegating it as a separate function?

Thanks for asking about this! Here are my thoughts:

I don't think I'll be able to provide anything better than what already exists in the Python concurrent.futures module as far things like as_completed go. Definitely it would be possible for deco to support this kind of things, but I don't think deco should serve this purpose. Mainly it's just targeted at programmers who have little experience with parallel programming, I wanted to make it more accessible which in turn means deco needs to be simple. For simple programs I think deco can fill a certain need, but definitely for more complicated parallel programs other libraries will continue to be the best choice.

Your second question is a great thought, although I'm not sure there is a way in pure Python to annotate code at a granularity smaller than a function. Using decorators on functions also helps us avoid a lot more complicated data flow analysis which I think would otherwise be necessary if we were just annotating chunks of Python code.

I'm going to close this for now, but thanks for your input! I really appreciate it.