Numeric, has support for arrays of character data
(provided by the
numarray.strings module) in addition to arrays of
numbers. The support for character arrays in
Numeric is relatively
limited, restricted to arrays of single characters. In contrast,
numarray supports arrays of fixed length strings. As an additional
numarray design supports interleaving arrays of
characters with arrays of numbers, with both occupying the same memory buffer.
This provides basic infrastructure for building the arrays of heterogenous
records as provided by
numarray.records (see chapter
12). Currently, neither
provides support for unicode.
>>> import numarray.strings as str >>> s = str.array(['Smith', 'Johnson', 'Williams', 'Miller']) >>> print s ['Smith', 'Johnson', 'Williams', 'Miller'] >>> s.itemsize() 8
The character array is just like an array in numarray, except that now each element is conceptually a Python string rather than a number. We can do the usual indexing and slicing:
>>> print s 'Smith' >>> print s[:2] ['Smith', 'Johnson'] >>> s[:2] = 'changed' >>> print s ['changed', 'changed', 'Williams', 'Miller']
Send comments to the NumArray community.