Recursive functions and RAM | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Recursive functions and RAM

In recursive functions which manages RAM better, C++ or Python ?

19th Oct 2020, 12:11 AM
Sanjay Kamath
Sanjay Kamath - avatar
2 Answers
+ 1
Josh Greig 🆓 () 🤔
24th Oct 2020, 3:33 PM
Sanjay Kamath
Sanjay Kamath - avatar
+ 3
That depends if you want better performance or an easier developer experience managing memory leaks in RAM. The most efficient use of RAM and best performance goes to well written c++. c++ uses less RAM for a similarly good implementation since all data types are known and optimized at compile-time. For example, an int in c++ will take 4 bytes of RAM using most modern c++ compilers. Python's number usually takes 28 bytes. More details are given at: https://pythonspeed.com/articles/python-integers-memory/ The easiest management of RAM for programmers goes to Python. In Python, you can largely ignore memory leak concerns because it is all garbage collected like in Java. C++ requires programmers to be very careful about freeing up all blocks of memory when they're done using them.
21st Oct 2020, 8:41 AM
Josh Greig
Josh Greig - avatar