Eli Holderness

Pointers? In My Python? It's More Likely Than You Think

Your Python variables are secretly pointers. Learn how this affects everything from simple assignments to memory management, and write more robust code.

Pointers? In My Python? It's More Likely Than You Think
#1about 2 minutes

Understanding pointers as names for objects in memory

Pointers are names that refer to objects in memory, similar to how multiple names can refer to the same person.

#2about 5 minutes

Solving pointer aliasing with shallow and deep copies

Assignment creates a pointer alias, while the copy method creates a shallow copy and deepcopy creates a fully independent object.

#3about 3 minutes

The unexpected behavior of mutable objects in tuples

Using the `+=` operator on a mutable element within an immutable tuple can modify the element despite raising a TypeError.

#4about 7 minutes

Comparing object identity versus equality in Python

The `is` operator checks for identical object IDs, while the `==` operator checks for equivalence defined by the `__eq__` magic method.

#5about 4 minutes

How Python uses reference counting to free memory

CPython tracks the number of pointers to an object and frees its memory when the reference count drops to zero, which can be observed using the `__del__` method.

#6about 7 minutes

Using the garbage collector for cyclic references

The garbage collector is necessary to detect and clean up cyclic references, where objects point to each other and are unreachable from the namespace.

#7about 4 minutes

How finalizers can create garbage collection edge cases

A `__del__` method can resurrect an object by creating a new global reference, preventing garbage collection until the new reference is removed and collection is run again.

#8about 6 minutes

Q&A on garbage collection performance and common pitfalls

The performance impact of garbage collection depends on the program, and common mistakes include misusing global variables or overriding magic methods without care.

Related jobs
Jobs that call for the skills explored in this talk.

job ad

Saby Company
Delebio, Italy

Intermediate

d

Saby Company
Delebio, Italy

Junior

Featured Partners

Related Articles

View all articles
BB
Benedikt Bischof
Python Basics
2021 was a year of celebration for one of the most popular programming languages (according to Stack Overflow) as it turned 30. We are talking about Python of course.Its story begins in 1989 around Christmas and Guido van Rossum thought about a holid...
Python Basics
CH
Chris Heilmann
WeAreDevelopers LIVE days are changing - get ready to take part
Starting with this week's Web Dev Day edition of WeAreDevelopers LIVE Days, we changed the the way we run these online conferences. The main differences are:Shorter talks (half an hour tops)More interaction in Q&AA tips and tricks "Did you know" sect...
WeAreDevelopers LIVE days are changing - get ready to take part
CH
Chris Heilmann
Dev Digest 134 - Where pixels sing?
News and ArticlesWeAreDevelopers LIVE Data and Security Day is on Wednesday, 25/09/2024. Learn about OPC UA Updates, Best Practices for Using GitHub Secrets, Passwordless Web 1.5, Emerging AI Security Risks, Data Privacy in LLMs and get a chance to t...
Dev Digest 134 - Where pixels sing?
CH
Chris Heilmann
All the videos of Halfstack London 2024!
Last month was Halfstack London, a conference about the web, JavaScript and half a dozen other things. We were there to deliver a talk, but also to record all the sessions and we're happy to share them with you. It took a bit as we had to wait for th...
All the videos of Halfstack London 2024!

From learning to earning

Jobs that call for the skills explored in this talk.

Python Developer

Python Developer

Runtime Group Ltd

75K
Intermediate
NumPy
DevOps
Pandas
Docker
+6