Message270118
As usual, thank you for the detailed and informative answer, Eryk. I think I understand your points but I decided to do it the way I did it because:
1. I sometimes need the array itself. For example, some of my clases contains or inherits from a ctypes structure with pointers (to an array of memory). Usually I name these pointers with a leading underscore and expose them as properties returning ctypes arrays.
2. For pickling/unpickling ctypes arrays provide a convenient middle-point between bytes objects and ctypes pointers. Getting a bytes object from an array is as easy as calling bytes() on it. OTOH, the array can be directly assigned to a compatible pointer structure field.
3. While the overloaded c_array(ptr, size)/c_array(type, bytes) is not the most efficient api to get bytes from a pointer and viceversa, it's very simple for the range of uses cases (1 and 2) it covers. Nevertheless, I have benchmarked the perfomance and it's not that terrible. |
|
Date |
User |
Action |
Args |
2016-07-10 18:10:35 | memeplex | set | recipients:
+ memeplex, amaury.forgeotdarc, belopolsky, meador.inge, eryksun |
2016-07-10 18:10:35 | memeplex | set | messageid: <1468174235.1.0.245386467845.issue27274@psf.upfronthosting.co.za> |
2016-07-10 18:10:35 | memeplex | link | issue27274 messages |
2016-07-10 18:10:35 | memeplex | create | |
|