So I'm writing a game in Python, and a problem I'm trying to solve requires that I turn a 2D list (that is, a list of lists) into a 1D list. I've seen several ways to do this, but I don't know if any of them create copies of any objects held within or just new references. To be honest, the Python standard library confuses me in that it's not always obvious whether objects/sequences are copied or just filled with references.
These are the assumptions about my particular situation;
- We can assume that my 2D list, if represented as a matrix, is perfectly rectangular.
- It'd be nice if I could have a solution for which the above assumption isn't true, but it's not required at the moment.
- No need to worry about 3D+ lists.
Thanks!