-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return raw array data for further processing with numpy #63
Comments
Update: I compared the normal implementation with the one i quickly patched to return a normal ctype array. The speedup is up to factor 20.
First is 0.166s per call, second is 0.008s per call. |
@pyhannes That is definetely a massive amount of time it takes to convert to a Python list. Thanks for bringing that up. I think my preferable way to go here is to add a parameter |
I added a parameter return_ctypes to read functions to allow omit the conversion to Python data types. |
I'm transferring several float arrays with millions of samples each second by using read_by_name with PLCTYPE_ARR_REAL(1000000).
After profiling i noticed the function is spending most of its time in converting the ctypes array to a Python list:
if type(data_type).__name__ == "PyCArrayType": return [i for i in data]
Adding a "raw" argument, that returns the ctypes array directly, and reading it into a numpy array via np.frombuffer afterwards/manually reduces the time spent in this function by ~80% and increases the overall throughput a lot.
The text was updated successfully, but these errors were encountered: