5 ms·
How do you do that? Even if you can, it's unlikely to give you a 10-100x speedup, which other languages can often give you compared to Python. The garbage coll
by FartyMcFarter 6y ago
How do you do that?
Even if you can, it's unlikely to give you a 10-100x speedup, which other languages can often give you compared to Python. The garbage collector does not take anywhere near even half of the CPU time.
- mrfusion 6y agoimport gc gc.disable() Call gc.collect() when you’re at a good point to afford it and need it. Ive done this before in really deep inner loops where speed is important and shaved some significant time off. It’s also useful if you have something time critical and don’t want to be interrupted. Eg Profiling, etc.
- fulafel 6y agoThis affects only the cycle detecting part of Python's GC, most of the work is done by the refcounting system which you can't stop or pause.
- mrfusion 6y agoTo reply to your point. Others were saying the python is slower because of garbage collection. I’m just suggesting they try turning it off. Big fat downvote though :-(