Python Forum

Full Version: What work faster and take less memory array or class?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello.
I use Python 2.7

What the deference in time and space complexity between using classes and arrays?
I have class A. Class A have not any methods, only container of fields.
And map of instance of class A. Let it be m1. 

Also I have array which contains same data as fields of class A
and map m2 with instance of such arrays.


number of instances in m1 and m2 are same and data is same.
My question is:
Which map will takes more memory and working faster m1 or m2? And how much?

In fact my question is:
What work faster and take less memory array or class and if we have huge amount of instances? And how much?

Thank you.
Very unclear question.
Isn't this question sort of like:
Which runs faster a red ant or a green beetle