devito
devito copied to clipboard
pickling, singletons, and comparison
We have several objects that should be instantiated as singletons (e.g., LEFT, RIGHT, ... FORWARD, BACKWARD, ...) but they are not. This causes a subtle issue upon unpickling when these objects are compared. For example:
- upon unpickling, an
IterationDirection
is reconstructed along with a completely newBackward
... - ... but this
Backward
will be different from theBackward
created inspace.py
this causes is
comparisons to fail. Which led to PR #813 .
With singletons we should be able to elegantly fix this
we might be able to turn Tag
into a singleton generator and then just have something along the lines of
LEFT = Tag('Left')(...)
I think what we actually need to do is using python's Enum
I've promoted this to a bug.
But I'm closing PR #813 for now because I prefer to introduce the concept of singletons so that is
comparison works even after unpickling