Skip to content

Instantly share code, notes, and snippets.

@eduardogpg
Last active November 12, 2024 17:18
Show Gist options
  • Save eduardogpg/4ae05f571a13a5625c02af575b042d21 to your computer and use it in GitHub Desktop.
Save eduardogpg/4ae05f571a13a5625c02af575b042d21 to your computer and use it in GitHub Desktop.
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