5 ms·
Yeah. However you have the option to not pause if it is important. You can control where the memory management happens. You can either keep references to the me
by throwaway12iii 8y ago
Yeah. However you have the option to not pause if it is important. You can control where the memory management happens. You can either keep references to the memory, and call gc.disable(). When you are ready you can let go the references and enable the gc.
PyPy now lets you control where memory management happens. Making it possible to control worst case performance. For many production apps this is a big deal.
- mattip 8y agoYou can never prevent the GC cycle in CPython at the end of a block (context). You can only prevent the GC that tries to break reference cycles. If your class does crazy things at destruction, like "time.sleep(10)", and you create an instance of the class inside a function, when that function returns you will pause CPython even if you call gc.disable() You also cannot disable the minor collections in PyPy, only the major collections, but once the JIT kicks in PyPy can prevent some of the object churn by optimizing instances away.
- throwaway12iii 8y agoYeah. Avoiding slow things like classes, threads and adding time.sleep(10) is the trick.