I have several classes, and want to work with their collections like with a DB (or Django ORM, but simpler). Working with a DB would be a huge overhead, so I’d prefer having similar functionality in memory:
>>> node = Nodes.create(lat=X,lon=Y)
>>> node.id
1
>>> Nodes.all()
[<Node 1>]
>>> Nodes[1] # by id
[<Node 1>]
>>> way_nodes = map(Nodes.create, ((X, Y), (Z, W)))
>>> way = Ways.create(way_nodes)
>>> way.nodes
[<Node 2>, <Node 3>]
>>> way.id
1
This is basically all what I need. Is there anything similar in Python or in custom packages?
If none, and I have to write my own, what’s the best choice to inherit from?
Those seem like pretty basic requirements, why not code them into your classes?