Quick Reference · the language, current as of 3.14

python 3.14 cheat sheet

The everyday language on one page — types, structures, flow, functions, and classes — plus what actually changed in 3.14 (released 7 Oct 2025): t-strings, deferred annotations, an officially-supported free-threaded build, and subinterpreters. The mental model to hold: everything is an object, and a variable is just a name bound to one.

syntax & basics data structures flow & functions classes & typing built-ins & stdlib new in 3.14 gotcha most common

Distilled & cross-checked against: docs.python.org/3.14 (What's New · Language & Library Reference) · peps.python.org (649·734·750·758·765·768·779·784) · realpython.com · InfoWorld

How your code runs — and what a variable really is
EXECUTION MODEL your_code.py source text you write this bytecode compiled ops (.pyc) dis.dis() to peek CPython VM evaluates each opcode the interpreter loop result objects · output compile run 3.14 RUNTIME OPTIONS (OPT-IN) free-threaded · no GIL JIT · PYTHON_JIT=1 tail-call interp · +3–5% OBJECT MODEL — “names, not boxes” x a name (variable) bound to x = 42 an object on the heap id()0x7f… (identity) type()int value42 A variable never “holds” a value — it is a label pointing at an object. Assigning re-points the label; it never copies. That single fact explains aliasing, is vs ==, and every mutable-default surprise below.

What's new in 3.14 headline features

The changes worth learning first. Everything else on this page is the language you already know — these are the genuinely new moves.

Template strings (t-strings) PEP 750

Like an f-string but with a t prefix — it returns a Template (static parts + Interpolations) instead of a str, so you can escape/transform values before rendering. The safe way to build HTML, SQL, or shell.

from string.templatelib import Interpolation
tmpl = t"Hi {name}!"   # not a str
type(tmpl)  # string.templatelib.Template
for part in tmpl: ...  # process safely

Deferred annotations PEP 649 / 749

Annotations are now evaluated lazily, only when read. Forward references no longer need quotes, definitions are cheaper, and the new annotationlib introspects them in VALUE / FORWARDREF / STRING form.

def f(a: Node) -> Node:  # no "Node" quotes
    ...
from annotationlib import get_annotations, Format
get_annotations(f, format=Format.STRING)

Free-threaded Python PEP 779

The no-GIL build is now officially supported (not experimental). Threads can run Python bytecode truly in parallel. Opt in with the t build (e.g. python3.14t); single-thread cost is ~5–10%.

# the free-threaded interpreter
$ python3.14t
>>> import sys
>>> sys._is_gil_enabled()
False

Multiple interpreters PEP 734

Subinterpreters reach the stdlib via concurrent.interpreters — isolation of processes with the efficiency of threads (no sharing by default). Pair with InterpreterPoolExecutor.

from concurrent import interpreters
interp = interpreters.create()
interp.exec("print('hi from a sub!')")

except without brackets PEP 758 / 765

List several exception types with no parentheses (when there's no as). And PEP 765 now warns if a return/break/continue silently escapes a finally block.

try:
    connect()
except TimeoutError, ConnectionError:
    retry()          # no () needed

Stdlib & tooling polish 3.14

Zstandard via compression.zstd; pathlib.Path.copy()/move(); functools.Placeholder; attach a debugger to a live PID (pdb -p); a colorized REPL with import autocomplete; and python -m json.

from compression import zstd
zstd.compress(data)
$ python -m pdb -p 1234   # live attach
$ python -m json data.json
01Run & Environmentpython3.14
02Variables & Typesbind a name
03Operatorscombine values
04Stringsimmutable text
05Listsordered · mutable
06Tuples & Setsfixed · unique
07Dictionarieskey → value
08Control Flowindent = block
09match / casestructural · 3.10+
10Comprehensions & Generatorsbuild lazily
11Functionsdef & return
12Iterating Wellskip range(len())
13Classes & OOPeverything's an object
14Dataclassesstructs, minus boilerplate
15Modules & Importsreuse code
16Exceptionstry · except · finally
17Files & Pathsread · write · path
18Type Hintsoptional, checked offline
19Standard Library Picksbatteries included

Four pictures worth holding in your head

The models that turn a pile of syntax into intuition — references, slicing, scope, and the new t-string pipeline.

names & objects — mutable vs immutable

Assignment copies a reference, never the object. Two names can share one mutable list; rebinding an immutable int just re-points one name.

a = [1,2]; b = a; a.append(3) a b [1, 2, 3] both see 3 x = 1; y = x; x += 1 x y 2 1 x moved y stayed

slicing — seq[start:stop:step]

stop is exclusive. Negative indices count from the end. Omit any part; [::-1] reverses the whole sequence.

P Y T H O N 012 345 -6-5-4 -3-2-1 "PYTHON"[1:4] → "YTH"

scope resolution — LEGB

A bare name is looked up outward: Local → Enclosing → Global → Built-in. The first match wins; global/nonlocal let you write outward.

Built-in — len, print, range… Global — module top level Enclosing — outer function Local — this function lookup goes outward →

f-string vs t-string 3.14

An f"" renders to a str immediately. A t"" hands you the parts first, so your code can escape or transform interpolations before anything is rendered.

f"Hi {user}" str — done, unescaped t"Hi {user}" Template "Hi " (static) Interpolation(user) your html()/sql() → safe output you control the render

Worth memorizing

is ≠ ==is = same object · == = same value. Use is only for None
mutable defaultdef f(x=[]) shares one list across calls — use x=None
[[0]*3]*3three refs to ONE row — build with a comprehension instead
falsy values0 · '' · [] · {} · None · 0.0 are all false
= aliases= shares · .copy()/[:] shallow · deepcopy full
dict orderinsertion order is guaranteed since 3.7
{x=}f-string prints x=<value> — instant debug print
enumerate/zipreach for these before range(len(...))
except A, B:3.14 drops the parens — but (A, B) as e still needs them
3.14 GCincremental GC (3.14.0–3.14.4) was reverted to generational in 3.14.5+