The World’s Largest Online Community for Developers

'; python - Argument passing takes a lot of time - LavOzs.Com

I am trying to use c++ for faster list loop check from python with ctypes. The problem is that making an argument (don't know how to call it...) takes a lot of time, while function itself is very fast

I am passing a big list (image).

arra = cv2.imread('../smthg.jpg').reshape(1000*1000*3)
lib = ctypes.CDLL('./')
lib.function.restype = ndpointer(dtype=ctypes.c_int, shape=(1000*1000*3,))
arr = (ctypes.c_int * len(arra))(*arra) ### very slow (~1.4s)
res = lib.function(arr) ### the function itself
How to get the current time in Python
How can I make a time delay in Python?
How do I pass a variable by reference?
“Least Astonishment” and the Mutable Default Argument
Argparse optional positional arguments?
error: passing xxx as 'this' argument of xxx discards qualifiers
Should I put #! (shebang) in Python scripts, and what form should it take?
Speed comparison with Project Euler: C vs Python vs Erlang vs Haskell
Measure time elapsed in Python
PHP vs python, performance issue in php