[Python-Dev] Cost-Free Slice into FromString constructors--Long

Josiah Carlson jcarlson at uci.edu
Thu May 25 18:00:44 CEST 2006


Bob Ippolito <bob at redivi.com> wrote:
> One problem with buffer() is that it does a memcpy of the buffer. A  
> zero-copy version of buffer (a view on some object that implements  
> the buffer API) would be nice.

Did buffers change?  I seem to remember that there were segfaulting
conditions when using array and buffer due to arrays being resizable and
leaving buffers pointing at ether...or is the memcpy part of the buffer
'fix'?  If so, the changes in performance and memory use may surprise
long-time users of buffer.

 - Josiah

P.S. There is a possible solution to the "buffer pointing at ether due
to realloc" problem, but it would rely on a non-existing (from what I
understand about memory allocation) "would a realloc of pointer foo
point to the same address?"  Of course the other alternative is to just
always alloc when resizing arrays, etc., leaving a version of the old
object around until all buffers pointing to that object have been freed.



More information about the Python-Dev mailing list