I have data that is best represented by a tree. Serializing the structure makes the most sense, because I don\'t want to sort it every time, and it would allow me to make persis
Without trying it out I'm fairly sure the answer is:
Also, you mentioned shelve. From the shelve documentation:
The shelve module does not support concurrent read/write access to shelved objects. (Multiple simultaneous read accesses are safe.) When a program has a shelf open for writing, no other program should have it open for reading or writing. Unix file locking can be used to solve this, but this differs across Unix versions and requires knowledge about the database implementation used.
Personally, at this point, you may want to look into using a simple key-value store like Redis with some kind of optimistic locking.