Documentation Index

structarray

StructArray allows you to perform fast arithmetic operations on arrays of structured (or unstructured) data.

There are two classes you need to worry about: Array and StructArray.

Array does most of the work. It provides a simple array of numbers. Any operation performed on the array will be done on each item in it, blazing fast. Multiple arrays of the same length can be added/subtracted/multiplied/divided together, with the result stored in another array.

StructArray provides an almost object-oriented approach. You pass a list of attribute names and StructArray creates an Array for each one. However, getting an item from the StructArray returns an object mapping each array's value to it's attributes, making it easier to work with a single item. The data is also interleaved together, making it suitable for use as an OpenGL vertex array.

Notes on multidimensional arrays:

Multidimensional arrays are mostly just a painsaver for item indexes. array[x, y] is identical to array[x+y*width]. If fact, both forms of are valid for a multidimensional array. len(array) always returns the number of items in the array, not the length in any particular direction.

There is an additional restriction on multidimensional arrays: they cannot be resized. (This restriction could be lifted if there is demand.)

Classes

Functions

array_max

array_max(a, b)

Finds the maximum of each item in a and b.

Like the aritmetic operators, this doesn't return a new array, but an operation object that you can assign to an array. (Or call .copy() to create a new array)

array_min

array_max(a, b)

Finds the minimum of each item in a and b.

Like the aritmetic operators, this doesn't return a new array, but an operation object that you can assign to an array. (Or call .copy() to create a new array)