Quick Recap

  • We can’t use the “assignment expression” operator (a.k.a the walrus operator) at the top level without parenthesizing. Iterable unpacking isn’t supported either, so be careful when you see something like (a := 6, 9).
  • String interning and constant folding are some of the optimizations implemented for strings to improve efficiency.
  • Integers from -5 to 256 are pre-allocated in Python memory for faster access. Similar optimizations apply to other immutable objects, like empty tuples.
  • The interactive interpreters (like IPython) have certain differences in design (like more global variables, different compile units, etc.), which can lead to different execution behavior compared to the compiled Python files.
  • 0 <= x <= 100 is a more Pythonic way to write 0 <= x and x <= 100. In general, a op1 b op2 c op3 d.. is equivalent to a op1 b and b op2 c and c op2 d ... where a, b, c and d are any objects and op1, op2, op3 are some operators.

Get hands-on with 1200+ tech skills courses.