问题
I have a bunch of numbers that I have to organize and am thinking of organizing in lists them by their semantic meaning.
What is the overhead in terms of memory usage of organizing data as a list of lists versus a single flat list in python?
I.e.
[[x1,y1,v1],[x2,y2,v2], ... , [xn,yn,vn]][x1,y1,v1,x2,y2,v2, ... , xn,yn,vn]
回答1:
There would be very, very little overhead. Organize your data in whichever way makes the most semantic sense, and don't worry about performance until it's actually a problem. In this case, it's highly unlikely that it would ever become an issue.
来源:https://stackoverflow.com/questions/31953873/list-of-lists-vs-single-list-memory-usage-in-python