@Simd it is your responsibility to keep your file handle, like file_handle = open("file.pkl", "rb"); obj = pickle.load(file_handle); close(file_handle)
or with statement handles automatic closing for you
or if you're on 3.8 or later, pickle.load(file_handle := open(...)) is also an option
I guess GCs don't usually call the C free, but when the refcount reaches 0, does the GC immediately clean up and does CPython's own allocator immediately treat those objects as being free?
Unless, of course, you're code golfing, in which case you should definitely count on the file being closed by GC (or by the OS, or by rebooting your computer eventually). ;)
Why? If python decides the file is unused it will be closed. It's just that making sure you detect when something is unreferences with 100% accuracy is unfeasable
@DLosc I once saw a story somewhere about missiles whose software had memory leaks. It was okay for them because the missile would go kaboom anyway. I'm thinking we can treat normal computers the same way - they'll turn into trash at some point anyway
Critical Calculations
code-golfgamestatistics
Background
In the game stick ranger, there is an item which grants the character the ability to get critical hits.
Each time a projectile hits an enemy, it has some probability to be a critical hit (crit). For most weapons this is calculated and reset...
You roll $N$ dice simultaneously. Your score is the highest number rolled. If you play this game many times, what is the expected value (mean) of your score? Input A pos...