Await Is Not a Context Switch: Understanding Python's Coroutines vs. Tasks
31–40 of 79 posts
Re: Await Is Not a Context Switch: Understanding Python's Coroutines vs. Tasks
#32My New Year’s Resolution will be to give up complaining about this on hn, but for now: I find ChatGPT’s style and tone condescending and bland to the point of obfuscating whatever was unique, thoughtful and insightful in the original prompt. Trying to reverse-engineer the “Not this: That!” phrasing, artificial narrative drama & bizarre use of emphasis to recapture that insight and thought is not something I’m at all…
Are you saying this was generated by ChatGPT? It didn't seem that way to me at all... what gave that away to you?
dead giveaway
Re: Await Is Not a Context Switch: Understanding Python's Coroutines vs. Tasks
#33Earlier quoted context omitted.
Classic. I had a similar run-in with the CTO of a company a decade or so ago who point blank refused to use version control for the source code. He insisted on having directories that got zipped and passed around from developer to developer and good luck figuring out how to integrate someone else's changes. I won that particular battle but it was uphill all the way, at least he had the grace to afterwards admit that…
That is a very different run in.
Re: Await Is Not a Context Switch: Understanding Python's Coroutines vs. Tasks
#34> Awaiting a coroutine does not give control back to the event loop. I think this is a subtler point than one might think on first read, which is muddled due to the poorly chosen examples. Here's a better illustration: import asyncio async def child(): print("child start") await asyncio.sleep(0) print("child end") async def parent(): print("parent before") await child() # It prints: other parent before child start ot…
But isn't it true for JavaScript too? So I don't really get the author's point... am I missing something or the author('s LLM?) forced a moot comparison to JavaScript?
Edit: after reading the examples twice I am 99.9% sure it's slop and flagged it.
Edit2: another article from the same author: https://mergify.com/blog/why-warning-has-no-place-in-modern-...
> This isn’t just text — it’s structured, filterable, and actionable.
My conclusion is that I should ask LLM to write a browser userscript to automatically flag and hide links from this domain for me.
Re: Await Is Not a Context Switch: Understanding Python's Coroutines vs. Tasks
#35Sorry if I've got this wrong, but wouldn't the first example behave the same way in Javascript as well? The function parent() "awaits" the completion of child(), so it wouldn't be possible to interleave the print statements. The example from this StackOverflow question might be a better demonstration: https://stackoverflow.com/q/63455683
The whole article is bit of a mess. Like this thing: > My mutation block contained no awaits. The only awaits happened before acquiring the lock. Therefore: > * The critical section was atomic relative to the event loop. > * No other task could interleave inside the mutation. > * More locks would not increase safety. That is exactly the same as with e.g. JS. I'm sure there are lot of subtle differences in how Python…
[1] https://babeljs.io/docs/babel-plugin-transform-async-to-gene...
Re: Await Is Not a Context Switch: Understanding Python's Coroutines vs. Tasks
#36My New Year’s Resolution will be to give up complaining about this on hn, but for now: I find ChatGPT’s style and tone condescending and bland to the point of obfuscating whatever was unique, thoughtful and insightful in the original prompt. Trying to reverse-engineer the “Not this: That!” phrasing, artificial narrative drama & bizarre use of emphasis to recapture that insight and thought is not something I’m at all…
Are you saying this was generated by ChatGPT? It didn't seem that way to me at all... what gave that away to you?
From the words of ChatGPT itself:
> The post follows a “classic” structure: introduce a common misconception → explain what’s wrong → show concrete examples → give a clear takeaway / conclusion. The paragraphs are well balanced, each chunk delivering a precise logical step. While that’s good for clarity, it also can feel like the “standard template” many AI-based or marketing blog posts tend to follow.
Now, if could just be a very well written blog post too. But I feel that AI just naturally converges to the same basic structure, while a human written post generally will miss one or two of those "good practices" for prose that actually ends up making the blog post more interesting (because we don't always need to have all these structures to make something enjoyable to read).
Re: Await Is Not a Context Switch: Understanding Python's Coroutines vs. Tasks
#37> Awaiting a coroutine does not give control back to the event loop. I think this is a subtler point than one might think on first read, which is muddled due to the poorly chosen examples. Here's a better illustration: import asyncio async def child(): print("child start") await asyncio.sleep(0) print("child end") async def parent(): print("parent before") await child() # It prints: other parent before child start ot…
Re: Await Is Not a Context Switch: Understanding Python's Coroutines vs. Tasks
#38Re: Await Is Not a Context Switch: Understanding Python's Coroutines vs. Tasks
#39I may be misunderstanding it, but the examples shown don't seem to be illustrative? It seems reasonably obvious that the prints will happen in this order in any language, because in example 1 we are explicitly (a)waiting for the child to finish, and in example 2 both of the parent prints are above the await. So I don't feel like either of these makes the point the author is trying to get across?
I suppose the author meant to say that if you first called your async function and then later did `await` you would have different behavior.
Re: Await Is Not a Context Switch: Understanding Python's Coroutines vs. Tasks
#40My New Year’s Resolution will be to give up complaining about this on hn, but for now: I find ChatGPT’s style and tone condescending and bland to the point of obfuscating whatever was unique, thoughtful and insightful in the original prompt. Trying to reverse-engineer the “Not this: That!” phrasing, artificial narrative drama & bizarre use of emphasis to recapture that insight and thought is not something I’m at all…
tiring.
maybe someone will make an "article-to-prompt" sort of reverse ChatGPT?
But of course someone already did that, and of course it's inside ChatGPT, what was I thinking? Though if I do try it, the prompt I get is not especially pleasant to read: https://chatgpt.com/share/6926f33c-8f98-8011-984e-54e49fdbb0...