I'm asking you a question about cython reload().

Asked 2 years ago, Updated 2 years ago, 38 views

Hello,

I'm using cython for fast code execution I do reload() to reuse the module implemented as cyton as another parameter, but it doesn't work. It continues to run with the previous value, not the changed value.

import importlib
import pyximport; pyximport.install(reload_support=True)
from cythonGo import cythonModule_A

modeltext = "123"
modeltext_2 = "456"

cythonModule_A.build(modeltext)
cythonModule_A.run(~~~)

importlib.reload(cythonModule_A)
cythonModule_A.build(modeltext_2)
cythonModule_A.run(~~~)

When I googled, I was told to give reload_support=True and reload(), but this method doesn't work for me (python 3.6). Isn't there a good way?!

python cython

2022-09-21 23:16

1 Answers

Hello, I'm the author. Eventually, I couldn't find a way, so I took a method of physically reloading. I was going to write a batch script and reload it by spinning for loop, but I can call Python file with Python as below.

import os
for i in range(0,1000):
    path = "python R_signle.py {}".format(str(i))
    os.system(path)

If you know how to reload the cyton module from the Python file, please let me know.


2022-09-21 23:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.