numpy tutorial - understanding numpy iterators - iterating through an array gets the rows/subarrays - iterating through .flat gets a flat C-ordering (last index in) run-through - ndenumerate returns index and object - also a way to convert flat index to tuple (and perhaps vice versa) - dtype objects - reproduce standard types - construct generic (nested) types - sit in array header, tell us what's in the records; points to scalar type (Python type); have same attributes as arrays - 21 standard scalar types belong to hierarchy; some (int_, float_) enhance the corresponding Python type - the scalar types are classes; dtypes are a single class - byte order is handled in dtypes - advanced array slicing - slicing returns another view of the same data - advanced slicing is indexing by array objects - b[[0,1],[2,4]] returns b[0,2] b[1,4] - this is element by element behavior; the MATLAB cross product behavior is given by ix_ - b[:,[1,2]] returns b[:,1] b[:,2] - works by broadcasting - masked arrays: created boolean array, use it to index - a lot of this can be done with take - always copies data (demarcation by simple and fancy indexing; integers and slicing objects are always simple) - writing C code - numpy supports all the Numeric API - but all the dimensions and strides are integers the same size as the pointer on the platform - some calls remain that take int, and convert; a slightly different call would avoid the conversion - simple function to create array, PyArray_FROM_OTF - in book: using iterators, broadcast mechanism - numpy include in nonstandard location for compatibility with Python eggs, which have to be self-contained - numpy distutils will take that into account; there's also a get_include command - ctypes - straightforward (but cumbersome) way of directly calling C shared libraries from Python - requires some checks to be done on the Python side - and requires some introspection on the library (get the method names, etc.) - pyrex - lets you write code that mixes Python and C data types any way you want, and compiles it into a C extension for Python - weave - very nice, will compile on the fly, speed up array computations - or inline C/C++ code - memory mapped arrays - are useful for reading and/or modifying small segments of a large file with regular layout - limited to intsize-dependent filesize of platform - interesting also for files, generally - misc - empty creates empty array, float by default - look into Python eggs (jars for Python; platform-dependent if they include C extensions) - look into numpy distutils - array interface between Numeric, numarray, numpy; also PIL (1.1.6) - if "nocopy" specified, no memory hit - pytables: managing hierarchical datasets - pysparse: sparse matrices (Numeric-based)