Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does garbage collection make python slower?

OK, so we are developing an network related application where the user can upload their own python scripts to decide for an algorithm. Our code contains c and cython and python modules.

Since avoiding latency, memory footprint and minimal processing is critical for us, we were wondering if it's a wise and effective (performance wise) to turn off garbage collection and handle memory deallocation ourselves.

like image 700
theRealWorld Avatar asked Jun 23 '11 02:06

theRealWorld


2 Answers

Just let the language do what it wants to do, and if you find you have an actual problem, come on back and post about it. Otherwise it's premature optimization.

like image 66
John Zwinck Avatar answered Sep 27 '22 18:09

John Zwinck


gc.disable only turns off the cyclic garbage collector. Objects will still be collected when the refcount drops to zero anyway. So unless you have a lot of cyclic references, it will make no difference.

Are you are talking about doing a customised Python build and disabling the ref counting GC?

like image 37
John La Rooy Avatar answered Sep 27 '22 16:09

John La Rooy