guides
Concurrency and Multiprocessing
Combine Pyvorin with threading, multiprocessing, and async fallback.
Published May 30, 2026
Threading
Pyvorin-compiled functions release the GIL during pure computation, allowing true parallelism with threading:
from concurrent.futures import ThreadPoolExecutor
def worker(data):
return sum(x * x for x in data)
with ThreadPoolExecutor(max_workers=4) as ex:
results = list(ex.map(worker, chunks))
Multiprocessing
For CPU-bound workloads, use multiprocessing to bypass the GIL entirely:
from multiprocessing import Pool
def worker(data):
return compiled_transform(data)
with Pool(4) as p:
results = p.map(worker, chunks)
Async Fallback
Async/await is unsupported for native compilation but falls back gracefully to CPython. Use async for I/O boundaries and compiled sync functions for CPU work:
async def handle_request(data):
# I/O: CPython async
raw = await fetch_data(data['id'])
# CPU: compiled native
result = process_data(raw)
return result