Created
November 11, 2020 18:13
-
-
Save demiurg/0923c3084abbc364778c5be66b09de63 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numba as nb | |
| from concurrent.futures import ThreadPoolExecutor | |
| from multiprocessing import cpu_count | |
| @nb.jit(nogil=True) | |
| def slow_calculation(x): | |
| out = 0 | |
| for i in range(x): | |
| out += i**0.01 | |
| return out | |
| ex = ThreadPoolExecutor(max_workers=cpu_count()) | |
| futures = [ex.submit(slow_calculation, 100_000_000_000+i) for i in range(cpu_count())] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment