I would like to have nested structure with minimum memory allocation. This would need passing data by reference but i’m not able to enforce that explicitly.
I have a small number (i.e. 5) of different geometries. Each geometries includes lines and surfaces which includes themselves nodes.
And I have a high number (i.e. >2000) of simulation results with data and metadata. In the metadata I want to include the geometry, and because there is only 5 different ones i should access them by reference and not copy a full geometry object in each simulation result.
By putting the referenced object directly in the parent object it seems to copy it if i have an immutable object, and seem to pass them by reference for mutable object.
Howeer, my object should be immutable and i would prefer to pass a reference more explicitly.
For now the best solution i found is giving them
ids and setting a “children_id” field in my parent object. However this solution is not very handy as i need to do list comprehension and use filter every time i want to access an object :
filter(x -> x.id in [y.geometry_id for y in results], geometries)
I would like to be able to access struct with the fields syntax :
Is there an existing solution ? Or should write new methods for accessing my structs recreating the filter I want ?