Hi,
I recently read on the Numpy doc about numpy.chararray:
The chararray class exists for backwards compatibility with Numarray, it is
not recommended for new development. Starting from numpy 1.4, if one needs
arrays of strings, it is recommended to use arrays of dtype object_, string_
or unicode_, and use the free functions in the numpy.char module for fast
vectorized string operations.
Moreover, I found that numpy.recarray turns all Numpy strings dtypes into a
chararray instead of a ndarray of strings. Is there a reason?
Example:
import numpy as np
a = np.array([('babar', 42), ('celeste', 12)], dtype=[('name', '|S7'), ('age', np.int_)])
reca = a.view(np.recarray)
print type(reca.name) # => chararray
whereas a['name'] returns a ndarray of type |S7.
Can you think it's a relevant idea to have the same numpy type for a['name']
and reca.name? Thus, it would be possible to get rid of chararray in this case.
Thanks,
Damien G.