Re: [ctypes-users] Re: copying/slicing ctypes arrays, (c_ulong *n)()
Brought to you by:
theller
From: Thomas H. <th...@py...> - 2004-12-23 15:57:53
|
Florian Schulze <flo...@gm...> writes: > On Tue, 21 Dec 2004 19:50:24 +0100, Thomas Heller <th...@py...> > wrote: > >> I have thought about all this a little bit, and it seems that it would >> be very useful to accept Python objects which implement the buffer >> interface as function parameters (currently only ctype instances, >> strings and integers are allowed). >> >> Of course, sometimes you don't want the data to be copied just at the >> beginning, but in this case you should wrap the object into a buffer >> object (with the buildin buffer() type/function). The buffer() call >> accepts optional parameters for offset and size, so address arithmetic >> would be done by the buffer object itself - nicer than to add more >> parameters to the memmove function and friends. >> >> How does that sound? > > Sounds good. > > I wonder what the python developers plan to do with buffer in the > future, I read it's deprecated and should be redone. The buffer interface and the buffer object are separate things, the latter is not loved very much. There have been changes in Python 2.4 which make buffer objects somewhat safer. The address of the underlying object is no longer stored in the buffer object anymore, it's only retrieved when needed. But I don't have the energy to start another buffer discussion on python-dev right now, and since ctypes is dangerous anyway, the buffer object is fine imo. Thomas |