我还没有达到我有工具(或知道如何开发或使用它们)来测试和分析看似简单的事情(比如我的问题)的水平,所以我求助于你。
我有一个检查条件的函数,并根据该条件选择最好的数学工具(不同的模块),但这个函数应用于数组的窗口,因此是循环的。从一个窗口到另一个窗口可能会发生不同的导入,但这让我想知道导入是否真的被循环了,这是否是一个性能问题。
这是来自 matplotlib 源的示例
def pause(interval):
"""
Pause for *interval* seconds.
If there is an active figure it will be updated and displayed,
and the GUI event loop will run during the pause.
If there is no active figure, or if a non-interactive backend
is in use, this executes time.sleep(interval).
This can be used for crude animation. For more complex
animation, see :mod:`matplotlib.animation`.
This function is experimental; its behavior may be changed
or extended in a future release.
"""
backend = rcParams['backend']
if backend in _interactive_bk:
figManager = _pylab_helpers.Gcf.get_active()
if figManager is not None:
canvas = figManager.canvas
canvas.draw()
show(block=False)
canvas.start_event_loop(interval)
return
# No on-screen figure is active, so sleep() is all we need.
import time
time.sleep(interval)
如果我在循环中交替打开和关闭数字,是否会每隔一次迭代导入一次?或者只是在第一次调用导入时导入而忽略后续导入?
谢谢