Last active
November 12, 2024 17:18
-
-
Save eduardogpg/4ae05f571a13a5625c02af575b042d21 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
from multiprocessing import Process | |
import time | |
import os | |
from concurrent.futures import ProcessPoolExecutor | |
def fib(number): | |
if number <= 1: | |
return number | |
return fib(number - 1) + fib(number - 2) | |
if __name__ == '__main__': | |
start = time.time() | |
with ProcessPoolExecutor(max_workers=4) as executor: | |
generator_result = executor.map(fib, [35, 35, 35, 35]) | |
end = time.time() | |
print(f"Time taken: {end - start}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment