<legend id='tkbEV'><style id='tkbEV'><dir id='tkbEV'><q id='tkbEV'></q></dir></style></legend>
  • <i id='tkbEV'><tr id='tkbEV'><dt id='tkbEV'><q id='tkbEV'><span id='tkbEV'><b id='tkbEV'><form id='tkbEV'><ins id='tkbEV'></ins><ul id='tkbEV'></ul><sub id='tkbEV'></sub></form><legend id='tkbEV'></legend><bdo id='tkbEV'><pre id='tkbEV'><center id='tkbEV'></center></pre></bdo></b><th id='tkbEV'></th></span></q></dt></tr></i><div id='tkbEV'><tfoot id='tkbEV'></tfoot><dl id='tkbEV'><fieldset id='tkbEV'></fieldset></dl></div>
        <bdo id='tkbEV'></bdo><ul id='tkbEV'></ul>

      <small id='tkbEV'></small><noframes id='tkbEV'>

        <tfoot id='tkbEV'></tfoot>

        Python中的递归有多安全?

        How safe is recursion in Python?(Python中的递归有多安全?)
          <tbody id='BaA8R'></tbody>

          <i id='BaA8R'><tr id='BaA8R'><dt id='BaA8R'><q id='BaA8R'><span id='BaA8R'><b id='BaA8R'><form id='BaA8R'><ins id='BaA8R'></ins><ul id='BaA8R'></ul><sub id='BaA8R'></sub></form><legend id='BaA8R'></legend><bdo id='BaA8R'><pre id='BaA8R'><center id='BaA8R'></center></pre></bdo></b><th id='BaA8R'></th></span></q></dt></tr></i><div id='BaA8R'><tfoot id='BaA8R'></tfoot><dl id='BaA8R'><fieldset id='BaA8R'></fieldset></dl></div>

        • <small id='BaA8R'></small><noframes id='BaA8R'>

          <tfoot id='BaA8R'></tfoot>
              • <bdo id='BaA8R'></bdo><ul id='BaA8R'></ul>
                  <legend id='BaA8R'><style id='BaA8R'><dir id='BaA8R'><q id='BaA8R'></q></dir></style></legend>
                  本文介绍了Python中的递归有多安全?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在做一项 AI 作业,尽管我的教授提出了建议,但我无意用 lisp 写这个作业.但是,我确实想递归地编写它,以使其简洁明了.这是我的问题:

                  I'm working on an AI homework, and despite my professor's suggestions, I have no intention of writing this assignment in lisp. However, I do want to write it recursively, the better to keep it concise and simple. Here is my question:

                  如果我在大型状态空间上执行搜索,我是否会面临堆栈空间不足的重大风险?Python 堆栈有多深?

                  Am I running a major risk of running out of stack space if I perform a search over a large state space? How deep does the Python stack go?

                  推荐答案

                  Python 堆栈有多深?

                  How deep does the Python stack go?

                  python 中默认的递归限制是 1000 帧.您可以使用 sys.setrecursionlimit(n) 来更改它,风险自负.

                  The default recursion limit in python is 1000 frames. You can use sys.setrecursionlimit(n) to change that at your own risk.

                  如果您打算使用 python,我建议您使用更适合该语言的模式.如果您想使用递归样式搜索,并且需要任意堆栈深度,您可以利用 python 的增强生成器(协程)创建蹦床模式"(在 PEP342)

                  If you're set on using python, I would suggest using a pattern more suited to the language. If you want to use the recursive style search, and need arbitrary stack depth, you can make use of python's enhanced generators (coroutines) to create a "trampoline pattern" (there an example in PEP342)

                  尽管我的教授提出了建议,但我无意用 lisp 写这个作业

                  and despite my professor's suggestions, I have no intention of writing this assignment in lisp

                  如果该练习旨在基于递归,那么尾调用优化的语言(如 lisp)可能是您的最佳选择.

                  If the exercise is intended to be recursion-based, a tail-call optimized language, like a lisp, is probably your best bet.

                  这篇关于Python中的递归有多安全?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                  Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                  python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                  Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                  How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                  Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)
                    <tbody id='fbZ3u'></tbody>

                  <legend id='fbZ3u'><style id='fbZ3u'><dir id='fbZ3u'><q id='fbZ3u'></q></dir></style></legend>
                      • <small id='fbZ3u'></small><noframes id='fbZ3u'>

                        1. <i id='fbZ3u'><tr id='fbZ3u'><dt id='fbZ3u'><q id='fbZ3u'><span id='fbZ3u'><b id='fbZ3u'><form id='fbZ3u'><ins id='fbZ3u'></ins><ul id='fbZ3u'></ul><sub id='fbZ3u'></sub></form><legend id='fbZ3u'></legend><bdo id='fbZ3u'><pre id='fbZ3u'><center id='fbZ3u'></center></pre></bdo></b><th id='fbZ3u'></th></span></q></dt></tr></i><div id='fbZ3u'><tfoot id='fbZ3u'></tfoot><dl id='fbZ3u'><fieldset id='fbZ3u'></fieldset></dl></div>
                            <bdo id='fbZ3u'></bdo><ul id='fbZ3u'></ul>

                            <tfoot id='fbZ3u'></tfoot>