[Python-Dev] Coroutines and PEP 380 (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Sun Jan 22 00:22:56 CET 2012
- Previous message: [Python-Dev] Coroutines and PEP 380
- Next message: [Python-Dev] Coroutines and PEP 380
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Glyph wrote:
Yes, but you /can/ look at a 'yield' and conclude that you /might/ need a lock, and that you have to think about it.
My concern is that you will end up with vastly more 'yield from's than places that require locks, so most of them are just noise. If you bite your nails over whether a lock is needed every time you see one, they will cause you a lot more anxiety than they alleviate.
Sometimes there's no alternative, but wherever I can, I avoid thinking, especially hard thinking. This maxim has served me very well throughout my programming career ;-).
There are already well-known techniques for dealing with concurrency that minimise the amount of hard thinking required. You devise some well-behaved abstractions, such as queues, and put all your hard thinking into implementing them. Then you build the rest of your code around those abstractions. That way you don't have to rely on crutches such as explicitly marking everything that might cause a task switch, because it doesn't matter.
-- Greg
- Previous message: [Python-Dev] Coroutines and PEP 380
- Next message: [Python-Dev] Coroutines and PEP 380
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]