mbaghb
Members-
Content Count
4 -
Joined
-
Last visited
Everything posted by mbaghb
-
using python4delphi to call python function and get return result
mbaghb posted a topic in Python4Delphi
hi i working to a project that need run python function in delphi. i use python4delphi and writed some codes but that not worked properly. If anyone knows the answers to these questions, I would be very grateful if they would give me the answers 1- How to call a python function with array of double as argument through Python4Delphi and receive the result of the function, which type is array of doubles, in Delphi. 2- Is it possible to import numpy,scipy,... just once and not need to import them every time i call the python function function sLineBreak := #13#10; Script := 'import numpy as np' + sLineBreak + 'def CCalcCustomRegr(args):' + sLineBreak + ' some python code.......' + sLineBreak + ' return result '+ sLineBreak; i need call CCalcCustomRegr with array of doubles as argument. and get result value which is array of doubles type. -
using python4delphi to call python function and get return result
mbaghb replied to mbaghb's topic in Python4Delphi
thank you again. I checked a few things and finally, to build the my DLL project and avoid importing numpy , scipy, vmdpy,emd,PyEMD,... etc., for each function call, I implemented them in the "initialization" section. In this way, only calculations are performed in functions. Of course, as you said, there was no big difference in performance cost, it just got a little better. The point that I noticed is the large size of the DLL file, which is about 8 MB. Is this normal based on the functions of the library that should be loaded or is there a solution for it?What do you suggest to increase performance using DLL to calculate python scripts? And another point, is there a complete document of all functions, methods, etc. for P4D that I can download? i appreciate you for your attention and guidance and excuse me if i don't create new topic I thought that if someone wants to create a DLL file with p4d, they might have the same problems and they will find answers to their questions here. function PyInit:integer; var script:string; begin try if (not Assigned(PythonEngine)) then begin PythonEngine := TPythonEngine.Create(nil); PythonEngine.AutoFinalize:=true; PythonEngine.UseLastKnownVersion:=true; PythonModule := TPythonModule.Create(nil); PythonModule.ModuleName:='MyDelphiModule'; PythonModule.Engine:=PythonEngine; PythonEngine.LoadDll; script := 'import numpy as np'+ sLineBreak + 'from PyEMD import CEEMDAN'+ sLineBreak + 'from vmdpy import VMD'+ sLineBreak; GetPythonEngine.ExecString(UTF8Encode(script)); end; Result:=0; except Result:=1; end; end; initialization MaskFPUExceptions(True); PyInit; -
using python4delphi to call python function and get return result
mbaghb replied to mbaghb's topic in Python4Delphi
thank you. that is solved my problem for passing value from delphi to python script as argument. but i dont find solution to import numpy or scipy just once to the python script. actully i coding the dll in delphi to use it in mql5. i have some functions in python script that need numpy,scipy,... and no need import its every time i called functions. how to import its once when initalizing pythonengin and pythonmodule. that is very important for increase performance to get function result. -
using python4delphi to call python function and get return result
mbaghb replied to mbaghb's topic in Python4Delphi
I am watching webinar I,II video on YouTube. I hope to find the answers. Thank you.