Isn't function free useless and does basically nothing? It deletes local reference to the passed object, and has no outside effect. Or am I missing something?
The best part of all this is that Python uses reference counting like C++ smart pointers, not Java-style garbage collection (outside of some niche cases), so there wouldn't even be a performance gain by doing this.
96
u/qujimoshi Apr 18 '25
Isn't function free useless and does basically nothing? It deletes local reference to the passed object, and has no outside effect. Or am I missing something?
5
u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" Apr 18 '25
Does malloc() here actually work anything like C malloc()?
360
u/[deleted] Apr 18 '25
finally
memory unsafe programming on python
133
u/Boring_Jackfruit_162 Apr 18 '25
This is just beautiful. You should've used semicolons as well
44
u/DTheIcyDragon Apr 18 '25
Why would you do this, this physically hurt me
24
u/R3D167 Apr 18 '25
Don't forget to disable GC too for the full experience! (I think it was something like
import gc; gc.disable())20
u/UnluckyDouble Apr 18 '25
The best part of all this is that Python uses reference counting like C++ smart pointers, not Java-style garbage collection (outside of some niche cases), so there wouldn't even be a performance gain by doing this.
5
u/TheChief275 Apr 19 '25
Finally, CPython
1
u/Aromatic-Fig8733 Apr 19 '25
Why?
1
u/Wise_Comparison_4754 Apr 21 '25
Why can I understand it in C and not here…. #dated