Closed Almas-Ali closed 2 months ago
How can we deal with Memory Management and Garbage Collection you think?
Even I rarely use __del__
method.
What do you mean? Python already deals with GC for us; it would only be an issue if we tried to rewrite the project in a language like C or god-forbid C++
Was thinking about a manual process, not by Python's automatic GC.
But I don't think that would have any benefits over sticking with what we're doing now. If you think that writing our own GC in Python (like you seem to suggest) would bring any benefit, please explain
It should make speed improvement or give user a API to manage memory by them self. It's just a theory, I don’t have any Idea what and how to do this anyway!!
But Python code will always be slower than equivalent C, so getting speed improvements from writing our own GC makes no sense! As for the API, maybe we could expose the functions from Python's gc
module, but I don't really know if that would work out very well. Even if it doesn't, I don't think it's worth the speed toll.
In that case I think we need to stop this topic for now. We'll see if we need this in future.
Personally, I think this is a TERRIBLE idea. Just look at the Python docs and see how janky
__del__
is. It may never run, it may run during interpreter shutdown, when built-in functions likeprint
are already GC'd away, and if it does run, there are basically no guarantees about when. And having built Radon on top of Python's GC will only make it even worse.The alternative in my opinion would be a
__close__
method (or whatever the name may be) that would function in a construction similar to Python'swith
.