Stefan Behnel wrote:
>>> Good day.
>>> I am trying to obtain MAXIMUM speed for this mappings:
>>>
>>> MyString = '\n'.join([ ''.join([j.encode('utf8') for j in i]) for i
>>> in NdArrayList ])
>  
...
> Also, given that the retrieval of each of the substrings has a little
> overhead, I'd recommend copying the buffer content directly into a memory
> buffer, over-reallocating at need to avoid multiple copying. There are
> Python C-API methods that can then encode the resulting PyUNICODE buffers
> (assuming that a numpy "<U1" buffer is a PyUNICODE buffer) to a UTF-8
> string.
> 

the array.pxd (Python's array.array) of
http://trac.cython.org/cython_trac/ticket/314
http://trac.cython.org/cython_trac/attachment/ticket/314/array.zip

.. which may appear in one of the next Cython releases in some 
fashion, has ready made C-fast inline extend functions, efficient 
auto-growth,memory management etc already implemented.
cdef array.array a=array('u'/'c') or so.
What array_example.pyx shows in these lines in fast_cat()

         array.array_extend(a, b)
         ...
         array.array_extend_buffer(a, <char*>s, PyString_Size(s) )
         ...

may be quite near to what you want. taking the ndarr.data stuff 
instead.


Robert

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to