[ctypes-users] copying/slicing ctypes arrays, (c_ulong *n)()
Brought to you by:
theller
From: RJ <ra...@sa...> - 2004-12-15 04:48:08
|
I have some code that gets a data array from a Win32 A/D dll/driver call at 250,000 samples/sec in 2K chunks. It has the form: buf = (c_ulong * 2000)() which I then copy into a circular numarray buffer like: for i in range(2000): narray[pntr+i] = buf[i] which is a bit slow, but fine for much lower data rates. So, what is the fastest way copy the data? I was re-reading the Python speed FAQ - I'll try narray[pntr:pntr+2000] = map(None, buf) tomorrow, but is that right? Also, since narray is circular I sometimes need to split the ctypes buf in the copy when the pointer starts over, and ctypes does not seem to support slicing. So, I copy to a temp numarray and slice that, which seems sub-optimal. The only "problem" here is that at 250Ksmps/sec it does not leave a lot of processor time to do other things. Would it be best to use a large ctypes array instead of numarray as the circular buffer? I would still need to slice it though, with stepping, to do FFTs etc. Thanks, Ray Secret anti-spam filter-passing text. Include with reply: qwertyuiop |