Possible PEP - two dimensional arrays?

Ned Batchelder ned at nedbatchelder.com
Tue Jun 7 20:38:13 EDT 2016

On Tuesday, June 7, 2016 at 8:19:33 PM UTC-4, Harrison Chudleigh wrote:
> I was programming a computer game and found that while 1D arrays can be
> created using the module array, there is no module for two-dimensional
> arrays, unlike languages like C. Currently, the closest thing Python has to
> a 2D array is a dictionary containing lists.
> I propose that a module , 2DArray, be added to the standard library. This
> module will include:
> Assignment and retrieval on items on a two-dimensional, finite rectangular
> grid. Types are integer, float, character and string.
> Resizing the grid - parameters are old size and new size. Any new elements
> are initialized with a value of 0 for int, 0.0 for float and ' ' for string
> and character arrays.
> Removing elements. The parameter is the location. After removal, the value
> returned is 0 for int, 0.0 for float and ' ' for string and character
> arrays.
> A function, pop(), which removes elements from the grid and then returns
> them.
> Is this idea PEPable?

People who need arrays like this generally use numpy, which has good support
for N-dimensional arrays and all of the operations you'd like on them.

I don't think Python would consider adding something like this to the 
standard library since numpy is available.


More information about the Python-list mailing list