pdict.py at master from segfaulthunter/sandbox - GitHub. A PersistentHashMap for Python - so a functional data structure that does not allow changes, but provides a new structure with minimal change compared to an existing structure with substructure sharing to the original structure. A rather interesting implementation. There are also further explanations of the ideas behind it. And an alternative implementation of the same idea.