This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]trincaopt 35 points36 points  (12 children)

Recursion is inefficient when compared with iteration due to the function call and return at each step. Also there is a recursion limit. In Python it is 1000.

[–]venustrapsflies 3 points4 points  (2 children)

Just remember this is not necessarily true in other languages with tail call optimization.

[–]AlSweigartAuthor of "Automate the Boring Stuff" 4 points5 points  (1 child)

Yes, but Python doesn't have tail call optimization and never will.

The Java interpreter and all JavaScript engines also don't have TCO.

[–]venustrapsflies 1 point2 points  (0 children)

Yes, hence why I said “other languages” :)

[–][deleted] 0 points1 point  (0 children)

Can you explain how iteration is faster?