3 ms·
What is the time to actually run the iterator to the end and extract and print the solutions?
by mjd 11y ago
What is the time to actually run the iterator to the end and extract and print the solutions?
- masklinn 11y agoAs indicated in the second note, in CPython (2.7 or 3.4) it's roughly the same as the eager version. In pypy the lazy version is about 3 times slower than the eager version. Version from your post: > time python2.7 test_eager.py [(9567, 1085, 10652)] python2.7 test_eager.py 6.41s user 0.02s system 99% cpu 6.451 total > time python3.4 test_eager.py [(9567, 1085, 10652)] python3.4 test_eager.py 6.28s user 0.03s system 99% cpu 6.372 total > time pypy test_eager.py [(9567, 1085, 10652)] pypy test_eager.py 0.95s user 0.06s system 98% cpu 1.022 total Using `yield from` (3.4-only) and wrapping the solutions() call in a `list()`: > time python3.4 test_yield.py [(9567, 1085, 10652)] python3.4 test_yield.py 6.28s user 0.02s system 99% cpu 6.313 total Using chain.from_iterable + imap (or map in 3.4) and wrapping the solutions() call in a `list()`: > time python2.7 test_imap.py [(9567, 1085, 10652)] python2.7 test_imap.py 6.52s user 0.02s system 99% cpu 6.558 total > time python3.4 test_imap.py [(9567, 1085, 10652)] python3.4 test_imap.py 6.26s user 0.02s system 99% cpu 6.292 total > time pypy test_imap.py [(9567, 1085, 10652)] pypy test_imap.py 2.87s user 0.06s system 99% cpu 2.943 total Versions used: Python 2.7.10, Python 3.4.3, PyPy 2.6.0 with GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57); all from macports