You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importpycerdefsomeFunctionCalledFromTheCppFunction(var:int, var2:int):
returnvar+var2defsomePurePythonFunction(var:int, var2:int):
returnvar*var2@pycer.compileInline# Im not quite that familiar with how C++ functions in Python STD gets exposed to Python, but I would # imagine compileInline to take the source code of the function fed into it (in this case # someFunctionThatGetsCompiledAndCachedAtExecutionTime) and all of its external references (in this case # someFunctionCalledFromTheCppFunction), concatonate it into a single long string, translate the new string to C++ and then# transformation the C++ code to turn it into a Python exposed C++ module (perhaps using# https://pybind11.readthedocs.io/en/latest/basics.html#creating-bindings-for-a-simple-function ), compile it using a C++ # compiler of choice, like cl.exe or clang.exe and place the resulting binary dll/"module" file right next to the py file # (might need to rename the binary module to avoid naming conflicts) and finally, "compileInline" would then import and # return the newly created function). # Ideally it would also use some kind of alteration aware caching (maybe by storing the python source code somewhere and # during successive executions of compileInline check if the source code is the same as it was during the last call before # compiling)defsomeFunctionThatGetsCompiledAndCachedAtExecutionTime(var:int, var2:int):
returnsomeFunctionCalledFromTheCppFunction(var, var2)
theAnswerToTheUniverse:int=someFunctionThatGetsCompiledAndCachedAtExecutionTime(30,2)+somePurePythonFunction(5, 2)
print(f"theAnswerToTheUniverse: {theAnswerToTheUniverse}")
The text was updated successfully, but these errors were encountered:
Eg:
The text was updated successfully, but these errors were encountered: