News for hackers. Stuff that matters.
Re:How Python Asyncio Works: Recreating It from Scratch by xmcqdpt2 on Tuesday May 07, 2024 @07:18AM (#40284264)
I think the type signature and example makes the parent's point, frankly. It has three types, on of which is contravariant, two different usage of the yield keyword, and two exit points.

Now granted most uses of generators are simpler than that, but still that's a lot of special syntax. And if you are writing Python without type-checking, that's a lot of bookkeeping you'd have to do when reading code.

Re:How Python Asyncio Works: Recreating It from Scratch by maxbond on Tuesday May 07, 2024 @05:03PM (#40291446)
That type signature is gnarly, I agree. I've seen people get tripped up because they think the function is the generator, and are confused about what behavior to expect from concurrent readers of different instances of the generator (because they don't realize that they are different instances in the first place). So my position is more about how to work with Python effectively/understand it accurately than in defense of it's syntax.