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
It's my fix for making c / cpp code functions injections in one way to python. By using decorators from python it's wrapping def then look for it content. In example you can see its' raff!
what is working now
proof of koncept
simple wrapper / decorator
can get argument __type__:
_int_ directly from python
_array_ / _vector_ of _ctypes.c_*_ directly from python
unwrap / redecorate def build and imported
checker if it's need to update / rebuild .so (code change)
why to use it
As one line solution for native python .so file builder it's fast to make a function moved to native c / cpp where all the power is in your hands. Really good in situations where performance of your code in computing high / math
how to use it [ manual installation ]
get otcppwrapper.py file to your project
in your python
fromotcpwrapperimport*
wrap a MyDiv function for example
@otcppdefMyDiv( a: int=0, b: int=1 ) ->int:
''' int MyDiv( int a, int b ){ return a/b; } '''
It gets it's c/cpp code as comment in the def it can by any function you want. It this example it's division of two integers.
use it as normally you use def by
print( MyDiv( 6, 2 ) )
or
after invoking it once it's in cache then you can use
f=otDynoWith( 'MyDiv' )
print( f( 6, 2 ) )
It's making in background a .c files then it compiles it and in dynamic way import those files as .so library
This shows that light function are ok if not faster in python but if the amount of math is higher / more data to process it's ~15x faster in execution.
The text was updated successfully, but these errors were encountered:
yOyOeK1
changed the title
otcpp need REDME
otcpp do I need it or is there something beter?
May 5, 2023
yOyOeK1
changed the title
otcpp do I need it or is there something beter?
otcpp do I need it or is there something better?
May 5, 2023
yOyOeK1
changed the title
otcpp do I need it or is there something better?
python otcpp one line from def to .so - do I need it or is there something better?
May 5, 2023
Readme is needed for now.
otdm-cpp-wrapper aks otcpp
It's my fix for making c / cpp code functions injections in one way to python. By using
decorators
from python it's wrappingdef
then look for it content. In example you can see its' raff!what is working now
__type__
:_int_
directly from python_array_
/_vector_
of_ctypes.c_*_
directly from pythondef
build and imported.so
(code change)why to use it
As one line solution for native python
.so
file builder it's fast to make a function moved to native c / cpp where all the power is in your hands. Really good in situations where performance of your code in computing high / mathhow to use it [ manual installation ]
otcppwrapper.py
file to your projectMyDiv
function for exampledef
it can by any function you want. It this example it's division of two integers.def
byafter invoking it once it's in cache then you can use
It's making in background a .c files then it compiles it and in dynamic way import those files as .so library
example
https://github.com/yOyOeK1/oiyshTerminal/blob/main/otdm-cpp-wrapper/otcpp.py
it running
This shows that light function are ok if not faster in python but if the amount of math is higher / more data to process it's ~15x faster in execution.
The text was updated successfully, but these errors were encountered: