Skip to content
Languagesbeginner · 50 min

Python

Readable, batteries-included, dynamically typed. Know data types and comprehensions, mutability gotchas, generators, decorators, and the GIL's effect on concurrency.

Data types & comprehensions

Lists (mutable), tuples (immutable), dicts and sets are the core containers. List/dict/set comprehensions express map/filter concisely and run faster than equivalent loops. Beware the mutable-default-argument trap (`def f(x=[])`).

Generators & iterators

A generator function uses `yield` to produce values lazily, one at a time, with O(1) memory — ideal for large/infinite streams. Any object with `__iter__`/`__next__` is iterable. `range`, file objects, and many stdlib APIs are lazy by design.

Decorators & the GIL

A decorator wraps a function to add behaviour (logging, caching via functools.lru_cache, timing) without changing its body. CPython's Global Interpreter Lock means threads don't run Python bytecode in true parallel — use multiprocessing or async I/O for CPU- vs I/O-bound concurrency respectively.

Resources

Practice & test yourself

Take the quiz →