7 ms·
If you understand the internals they're anything but pythonic. Coroutines can be a zero overhead abstraction in the some cases. For example here is a test that
by EricWF 9y ago
If you understand the internals they're anything but pythonic. Coroutines can be a zero overhead abstraction in the some cases.
For example here is a test that verifies the optimized output for a simple (and misnamed) integer generator compiled at -O2. Notice the arguments to `print` are integer literals. (https://github.com/GorNishanov/clang/blob/Experiments/test/CodeGenCoroutines/O2-generator.cpp https://github.com/GorNishanov/clang/blob/Experiments/test/C...)
I'm no python expert, but I suspect C++ optimizes this code better.
- yzmtf2008 9y agoI think the point of being pythonic is that it's more friendly to the programmers. Bonus point if it's also optimized :)
- electrograv 9y agoI love seeing the difference between Python and C/C++ coder cultures: To a Python'er, bonus points are given for performance and friendly coding is nearly assumed. To a C++'er, bonus points are awarded for friendly coding, and performance is nearly assumed. (Even more, I love how we're seeing some convergence here: no-compromise improvements to weak spots on each "side" of the programming language spectrum.)