* Marc 'BlackJack' Rintsch: > On Wed, 28 May 2008 02:28:54 -0700, bearophileHUGS wrote: >> Dennis Lee Bieber, the ghost: >> >>> I'd have to wonder why so many recursive calls? >> >> Why not? > > Because of the recursion limit of course. And function call overhead in > Python is quite high compared to an iterative approach.
One of my pet projects[1, it's about building and searching trees] made heavy use of recursion in the beginning. I rewrote parts of it using iteration because I hit the recursion limit and suspected a performance hit as well. To my (mild) surprise, the rewrite didn't perform significantly better. My benchmarks only showed an improvement of a few percent in runtime. I didn't measure memory usage, though. J. [1] http://well-adjusted.de/mspace.py/ (Sorry, baerophile, I'll get back to you about this! My SNV working copy is currently a mess and I need to clean that up first.) -- I feel yawning hollowness whilst talking to people at parties. [Agree] [Disagree] <http://www.slowlydownward.com/NODATA/data_enter2.html> -- http://mail.python.org/mailman/listinfo/python-list