Is there any reason to use one over the other?
Do they have the same performance?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I tend to use
inlineCallbacksfor multistep initialization (such as auth) to some service where each subsequent step depends on a result from the previous step, for example. Other than these situations, I tend to find thatinlineCallbackscould lead to lazy programming that could slow down your app.Here’s an example:
If
call1andcall2are completely independent calls that you want to parallelize, this function will end up serializing those calls. To convert this to a parallelizing call you should:This way you get call1 and call2 running simultaneously, but you wait on the results as they come in. So, while it’s possible to get the same benefits out of stock deferreds, it seems
inlineCallbacksjust make it too easy to implement the former solution.Also, keep in mind that you still have to wrap
try...exceptblocks around all your yield calls, as they’re the only way to trap errbacks within your code (unless a calling function of aninlineCallbacksfunction handles the errback at that level).So, I find it’s not really a question of performance per se, but rather good habits that would make me recommend against
inlineCallbacksin general – they’re still great for quick code snippets, multi-stage initialization routines, or tests for example.