3 ms·
import 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
by mrfusion 6y ago
import 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.