Python import system in one idea: import checks sys.modules first, so a module runs once. 🐍
→ then sys.path, first match wins
→ circular import? import the module, use it later
→ lazy import is coming in 3.15
#Python#Coding
Python @property is a descriptor: a class with __get__ you can write yourself. 🐍
def __get__(self, obj, owner):
return self.fget(obj)
Runs on every read.
#Python#Coding
Python descriptors, in 4 images. 🐍
An object on the class with __get__ and __set__ runs when you read or assign an attribute. property is built from one.
#Python#Coding
Python memory management, in 4 images. 🐍
Reference counting frees most objects at once, and the garbage collector catches the cycles it misses.
#Python#Coding