<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:'times new roman', 'new york', times, serif;font-size:12pt"><div>Thank you for your answer.</div><div><br></div><div>My english is bad so I tried to describe my usecase with a small piece of code in python.</div><div><br></div><div>JB</div><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><br><div style="font-family:arial, helvetica, sans-serif;font-size:13px"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">De :</span></b> Dag Sverre Seljebotn <dagss@student.matnat.uio.no><br><b><span style="font-weight: bold;">À :</span></b> cython-dev@codespeak.net<br><b><span style="font-weight: bold;">Envoyé le :</span></b> Samedi, 27 Décembre 2008, 11h59mn 00s<br><b><span style="font-weight: bold;">Objet :</span></b> Re: [Cython] Numpy - Chararray and efficient indexing<br></font><br>If you have
stored Python strings, use "object" as the datatype.<br><br>If you have stored NumPy fixed-width strings, then the answer is that this is not supported by Cython. The problem is that there's no obvious semantics -- does one copy the whole string on access (wasteful + how to manage the memory?) or get a pointer to it (contrary to how the other types work), which Cython type would one use for the elements (perhaps a single struct containing a fixed-size char array?), and so on.<br><br>As I never had a use for this myself I have a hard time figuring out how it should work, but if someone has good ideas I may be able to implement it. A more detailed description of your usecase may help.<br><br>Dag Sverre Seljebotn<br>-----Original Message-----<br>From: aucun aucun <<a ymailto="mailto:boogaloojb@yahoo.fr" href="mailto:boogaloojb@yahoo.fr">boogaloojb@yahoo.fr</a>><br>Date: Friday, Dec 26, 2008 11:32 am<br>Subject: [Cython] Numpy - Chararray and efficient
indexing<br>To: <a ymailto="mailto:cython-dev@codespeak.netReply" href="mailto:cython-dev@codespeak.netReply">cython-dev@codespeak.netReply</a>-To: <a ymailto="mailto:cython-dev@codespeak.net" href="mailto:cython-dev@codespeak.net">cython-dev@codespeak.net</a><br><br><br>>Hello,<br>><br>><br>>I've tried to write a small function to merge two Numpy arrays of strings with Cython.<br>><br>><br>>I need to use efficient indexing. What I've done for array of integers :<br>><br>><br>>import numpy as np<br>>cimport numpy as np<br>>ctypedef np.int_t DTYPE_t<br>>cdef np.ndarray[DTYPE_t, ndim=1] vecteur_n = np.zeros(vecteur.shape[0], dtype=int)<br>>...<br>><br>><br>>But I don't know the equivalent of "ctypedef np.int_t DTYPE_t" for strings, or at least a way of getting around this.<br>><br>><br>>Thank you for the help,<br>><br>><br>>JB<br>><br>><br>><br>><br>><br>><br>><br>><br>> <br><br>_______________________________________________<br>Cython-dev mailing
list<br><a ymailto="mailto:Cython-dev@codespeak.net" href="mailto:Cython-dev@codespeak.net">Cython-dev@codespeak.net</a><br><a href="http://codespeak.net/mailman/listinfo/cython-dev" target="_blank">http://codespeak.net/mailman/listinfo/cython-dev</a><br></div></div><div style="position:fixed"></div></div><br>
</body></html>