I want to implement a structure as flexible as Matlab struct in python. I have looked at Matlab structure in Python [duplicate] but the difference is I want a flexible structure where the field names and the depth of the structure are not know in advance. So for example in Matlab you can say:
parent.child1.grandchild1=2
parent.child1.grandchild2=3
parent.child2.grandchild1.grand-grandchild1=1
without initializing thet struct with the field names. I want to implement a structure that can be called whenever a user (who is not used to python) wants to store the value of a measurement in the structure he is using. So the call can happen multiple times in a code. I have looked at nested defaultdicts but did not really find a solution. I have read that numpy array are normally used for this purpose, but how can I constantly add fields to a numpy array without loosing performance? Any help would be greatly appreciated.