Explain to me what the big deal with tail call optimization is and why Python needs it

前端 未结 4 938
夕颜
夕颜 2021-02-07 03:39

So apparently, there\'s been a big brouhaha over whether or not Python needs tail call optimization. This came to a head when someone shipped Guido a copy of SICP because he di

4条回答
  •  一整个雨季
    2021-02-07 04:23

    If you intensely want to use recursion for things that might alternatively be expressed as loops, then "tail call optimization" is really a must. However, Guido, Python's Benevolent Dictator For Life (BDFL), strongly believes in loops being expressed as loops -- so he's not going to special-case tail calls (sacrificing stack-trace dumps and debugging regularity).

提交回复
热议问题