how to reload a cython module interactively using pyximport

后端 未结 1 799
我在风中等你
我在风中等你 2020-12-09 03:31

When writing python code, my typical workflow is to use the interactive prompt and do something like

write function
repeat until working:
  test function
  e         


        
1条回答
  •  轮回少年
    2020-12-09 03:40

    I found a poorly documented feature in the "pyximport.install" function that allows a cython module to be reloaded. With this feature set to True, you can load/reload your cython modules interactively without having to restart python.

    If you initialize your cython module with:

    import pyximport
    pyximport.install(reload_support=True)
    import my_functions as mf
    

    You can make changes to your cython module, and then reload with:

    reload(mf)
    

    Hopefully this will be of use to someone.

    0 讨论(0)
提交回复
热议问题