UFL

Support pickling FormData

Registered by Graham Markall

Support pickling FormData objects so that FFC analysis can be saved to disk.

Blueprint information

Status:
Complete
Approver:
None
Priority:
Medium
Drafter:
None
Direction:
Approved
Assignee:
None
Definition:
Approved
Series goal:
Accepted for 1.1.x
Implementation:
Implemented
Milestone target:
None
Started by
Martin Sandve Alnæs
Completed by
Martin Sandve Alnæs

Related branches

Sprints

Whiteboard

In order to build a test harness suitable for testing PyOP2 code generated by
FFC, it is necessary to save the analysis performed by FFC so that the test
harness can use the information contained within it to invoke the generated
code correctly. One way of saving and re-loading this analysis is to use the
pickle module.

Because the __new__ method of several UFL classes take more than just the cls
argument, the pickle module cannot successfully unpickle them, as it calls
Class.__new__(cls) unless told otherwise. To tell it otherwise, the
Class.__getnewargs__ method needs to be defined.

In the branch lp:~grm08/ufl/pickle __getnewargs__ has been added in order to
allow all the FFC examples to be pickled and unpickled correctly.
test_pickle.py tests for the correctness of the pickling and unpickling.

Any comments would be appreciated, especially regarding:

* Is pickling objects the right approach? Is there a better one that should
  be adopted instead?
* Are there other test cases that should be implemented?
* What are the thoughts on eventually merging this into the UFL trunk?

MSA: I have a question: the generic operator implementation of __getnewargs__ returns all operands, but the Variable and Indexed implementations return (), why is that? Because they don't have a __new__ overloaded?

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.