Free preview.You're sampling one lesson — enroll free to unlock all 8 lessons and track your progress.
Enroll free
lesson

Concurrency vs. Parallelism

Concurrency vs. Parallelism

In this lesson — part of Concurrency Basics — you'll learn concurrency vs. parallelism in Python and why it matters in real work.

Why it matters

Modern programs wait on networks and disks — async lets them stay responsive.

Key ideas

  • Blocking vs. non-blocking
  • Callbacks, promises, async/await
  • Concurrency vs. parallelism
  • Error handling in async code

In practice

Here's how it looks in idiomatic Python:

import asyncio

async def fetch(n):
    await asyncio.sleep(0.1)   # non-blocking pause
    return n * 2

async def main():
    return await asyncio.gather(fetch(1), fetch(2), fetch(3))

print(asyncio.run(main()))  # [2, 4, 6]

Python note: async/await runs on a single-threaded event loop; asyncio.gather() schedules coroutines concurrently and awaits them all.

Try it yourself

Exercise: In Python, fetch two things concurrently and combine the results.

Recap

You now understand concurrency vs. parallelism and can apply it in Python. Mark this lesson complete and continue to the next one.