The Real Python Podcast cover image

Exploring Duck Typing in Python & Dynamics of Monkey Patching

The Real Python Podcast

00:00

Understanding References and Immutable Objects in Python

Using Python, objects can have different references despite having the exact same name. While this concept holds true in a list comprehension, it differs in a for loop. The discussion touches upon edge cases related to handling references of immutable objects and the use of interned values. These interned values, like a set of integers and 'none,' have a single reference, impacting how they behave in the code. The explanation dives into how immortal objects work with 312, showcasing a unique behavior when using get ref count. The content emphasizes the nuances of naming objects, exploring references, and addressing potential confusion for beginners or intermediate Python users regarding Python's handling of references and objects.

Transcript
Play full episode

Remember Everything You Learn from Podcasts

Save insights instantly, chat with episodes, and build lasting knowledge - all powered by AI.
App store bannerPlay store banner
Get the app