Offline

Pointers, Objects, and References - How Python Manages Memory

Track:
Python Core, Internals, Extensions
Type:
Talk
Level:
beginner
Duration:
30 minutes
View in the schedule

Abstract

Most Pythonistas handle Python objects every day, but sometimes, the bugs and performance surprises we encounter happen because we misunderstand how Python actually manages memory. Variables are not just containers(which I previously thought), objects are not copied by default, and references behave differently than what many developers expect — especially as the codebases we work with grow. In this talk, we will build an accurate mental model of how Python handles objects, references, and memory at runtime; we will look at what really happens when objects are created, passed to functions, mutated, and destroyed. We will also look at how reference counting works at a high level, why mutability matters, and how these fundamental concepts come up when we examine debugging and performance in our Python code. After this session, developers will be more confident about their understanding of Python behaviour, avoid common pitfalls, and better understand what the profilers and debuggers are really saying.