Is it possible to use multidimensional arrays ?

bearophileHUGS at bearophileHUGS at
Sat Jun 6 18:46:26 EDT 2009

pdlem... at, if you are using Psyco and you aren't using
NumPy and you want max speed you may use:

NROWS = 24
NCOLS = 75
screen = array("H", [0]) * (NROWS * NCOLS)

and then you can use items like this:
screen[r * NCOLS + c]
(If NCOLS is equal or a bit lower than a power of 2 it's better to use
a shift).

But in most situations using lists of lists or NumPy is better.


More information about the Python-list mailing list