Cognitive load is the mental effort needed to understand or remember something. In software, reducing it leaves more attention for checking whether the program achieves its purpose. section 3.1.3
Reduce unnecessary cognitive load by making code easier to digest:
- Abstract related code into functions whose names clearly state their purpose. section 3.1.3
- Separate concerns into functions, methods, classes, or modules. section 11.5.1
- Break dense expressions across logical lines, rather than obeying arbitrary line limits or compressing code. section 9.1.1
def valuable_customers(customers):
return [
customer
for customer in customers
if customer.active
and sum(account.value for account in customer.accounts) > 1_000_000
]
Compare a compressed customer filter with a version that gives each condition room to form a mental model. section 9.1.1





