Python: Multi-dimensional array of different types
In many cases such arrays are not required as there are more elegant solutions to these problems. Explain what you want to do so someone can give some hints.
Anyway, if you really, really need such data structure, use array.array.
Is it possible to create a multi-dimensional array of different types in Python? The way I usually solve it is [([None] * n) for i in xrange(m)], but I don't want to use list. I want something which is really a continuous array of pointers in memory, not a list. (Each list itself is continuous, but when you make a list of lists, the different lists may be spread in different places in RAM.)
Also, writing [([None] * n) for i in xrange(m)] is quite a convoluted way of initializing an empty array, in contrast to something like empty_array(m, n). Is there a better alternative?