I've coded a typed dynamic list based on numpy array (needed for the glumpy
project).
Code is available from https://github.com/rougier/numpy-list
A Numpy array list is a strongly typed list whose type can be anything that can
be interpreted as a numpy data type.
>>> L = ArrayList( [[0], [1,2], [3,4,5], [6,7,8,9]] )
>>> print(L)
[[0], [1 2], [3 4 5], [6 7 8 9]]
>>> print(L.data)
[0 1 2 3 4 5 6 7 8 9]
You can add several items at once by specifying common or individual size: a
single scalar means all items are the same size while a list of sizes is used
to specify individual item sizes.
>>> L = ArrayList( np.arange(10), [3,3,4])
>>> print(L)
[[0 1 2], [3 4 5], [6 7 8 9]]
>>> print(L.data)
[0 1 2 3 4 5 6 7 8 9]
You can also us typed list for storing strings with different sizes:
>>> L = ArrayList(["Hello", "world", "!"])
>>> print(L[0])
'Hello'
>>> L[1] = "brave new world"
>>> print(L)
['Hello', 'brave new world', '!']
Nicolas
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion