Memeplex added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27274>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to