tobgu/pyrsistent

Allow multiple transform operations to be performed before checking invariants

Open

#89 opened on Jul 7, 2016

View on GitHub
 (2 comments) (0 reactions) (0 assignees)Python (1,943 stars) (141 forks)batch import
enhancementhelp wanted

Description

(I think this is basically the same issue that @tomprince reported in https://github.com/tobgu/pyrsistent/issues/73 but I can't re-open that issue.)

Here's a use case:

In https://github.com/ClusterHQ/flocker/pull/2806 we introduced a mechanism for calculating diffs between Pyrsistent structures.

A diff is itself a Pyrsistent object and comprises a sequence of _Add, _Set, and _Remove operations which translate to transform calls on the root object to which the diff is being applied.

When we perform these discrete operations on a structure containing objects with invariant checks we trigger InvariantErrors because the invariant check is performed after each operation.

Instead it would be better to delay all the invariant checks until the complete sequence of transformations has been performed.

One thought is that it'd be nice to be able to get a "recursive evolver" which provides the transform interface. And which can be recursively persisted so as to perform the invariant checks on the entire structure.

I've had a go at this in:

This may be related to the following issues: https://github.com/tobgu/pyrsistent/issues/73 https://github.com/tobgu/pyrsistent/issues/44

Contributor guide