New Features of NumPy
This list tries to summarize a few of the new features of
NumPy. There are more new features than these,
however.
- More data types (all standard C-data types plus complex floats,
boolean, string, unicode, and void *).
- Flexible data types where each array can have a different
itemsize (but all elements of the same array still have the same
itemsize).
- Data types are true Python objects
- Data types have a type attribute that is a typeobject placing the
data-type in a hierarchy of
data-types.
- Named fields are supported intrinsically on arrays. Record
arrays allow named-field access using attributes.
- Many more array methods in addition to functional counterparts.
- Attributes more clearly distinguished from methods (attributes
are intrinsic parts of an array so that setting them changes the array
itself).
- Array scalars covering all data types which inherit from Python
scalars when appropriate.
- Arrays can be misaligned, swapped, and in Fortran order in memory
(facilitates memory-mapped arrays).
- Arrays can be more easily read from text files and created from
buffers.
- Arrays can be quickly written to files in text and/or binary mode.
- Fancy indexing can be done on arrays using integer sequences and
boolean masks.
- Coercion rules are altered for mixed scalar / array operations so
that scalars (anything that produces a 0-dimensional array internally)
will not determine the output type in such cases.
- When coercion is needed, temporary buffer-memory allocation is
limited to a user-adjustable size.
- Errors are handled through the IEEE floating point status flags
and there is flexibility on a per function / module / builtin level for
handling these errors.
- One can register an error callback function in Python to handle
errors which are set to 'call' for their error handling;
- Ufunc reduce, accumulate, and reduceat can take place using a
different type then the array type if desired (without copying the
entire array);
- Ufunc output arrays passed in can be a different type than
expected from the calculation.
- Arbitrary classes can be passed through ufuncs (using
__array_wrap__ and __array_priority__).
- Ufuncs can be easily created from Python functions.
- Ufuncs have attributes to detail their behavior, including a
dynamic doc string that automatically generates the calling signature.
- Several new ufuncs (frexp, modf, ldexp, isnan, isfinite, isinf,
signbit).
- New types can be registered with the system so that specialized
ufunc loops can be written for fast support of new type objects.
- C-API enhanced so that more of the functionality is available
from extension modules.
- C-API enhanced so array structure access can take place through
macros.
- New iterator objects created for easy handling in C of
discontiguous arrays.
- Types have more functions associated with them (no magic function
lists in the C-code). Any function needed is part of the type structure.