In a project I have to store a sequence of successive rotations of an object in python. I intend to store them using scipy.spatial.transform.Rotation objects.
I have noticed that two options are available.
I store a multitude of Rotation object in an array, each Rotation object containing a single rotation of my sequence.
I store every rotation in the same Rotation object, effectively stacking them in a single object.
I wondered what were the trade offs between the methods in terms of computational speed and data access speed. And ultimately which method should be preferred.
In my particular case:
What I am looking for:
Thanks in advance.
Alright so I'll throw in the first elements I have.
For both you end up accessing an iterable and an object (just in a different order). Therefor there should not be any major difference in accessing speed.
The list of R is easier to access and manipulate afterwards. Hence if you are suceptible of changing anything in your rotation sequence it is the easier way. There for using a single object requires some extra-code for manipulation and might be slower. However it really depends on what you do and I have no data to prove that it is significantly slower.
The single object should take less memory space since there is only one instance, where as the list of object has nb_rotation times more. I already mentionned that this was not critical in my case it is not critical. Again I don't have any data to support this but I expect the difference to be significative since I have about 2'000'000 rotations.
Regarding those facts I would make the decision as follow:
If you're just looking to use the object for storage then the single object is probably more efficient. (However that would apply very specific cases since you could also compute the resulting rotation and store a single quaternion or rotation object)
If you're looking to manipulate your data in any way then the list of object seems more indicated for that. The only real draw back is memory use how ever if you manipulate the data you would also have to unpack the single object at some point, leading to a similar problem, if not worse due to data duplication.
In my case I will be using the list of object.