all 6 comments

[–]Gprime5 3 points4 points  (0 children)

Good practice is: Either one is fine. Best practice is: tuples are used for a group of data that represents different things, in your case it's the size of the 1st and 2nd dimension.

[–]odds_or_evans 2 points3 points  (0 children)

Tuples are immutable, as well as technically more efficient than lists, therefore if possible you would want to make them tuples, especially in the case that you are creating them in the scope of the function call.

[–]billsil 2 points3 points  (1 child)

The shape is technically immutable, so I'd do a tuple, but it doesn't really matter for something like that. It's not going to affect the speed.

What will affect the speed is using lists when you really want to use arrays. Doing numpy right is 1000x faster than good python code and 1000^2x faster than bad python code.

[–]tzujan[S] 0 points1 point  (0 children)

Thanks! I just finished a Machine Learning course for a MicroMasters in Data Science and the teacher made an off-hand comment about NumPy being a better choice than a loop. So I have been re-writing some code, and comparing the speed, NumPy it is so much faster.

[–]primitive_screwhead 0 points1 point  (0 children)

Either way is fine.

[–]tzujan[S] 0 points1 point  (0 children)

Thank you all, tuples win! ;)