Opened 4 years ago
Last modified 20 months ago
#8561 new enhancement
Implement PicklableFunction(interactive_function)
Reported by: | nthiery | Owned by: | nthiery |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | pickling | Keywords: | Pickling, lambda, interactively defined functions |
Cc: | sage-combinat | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
Extend sage.misc.fpickle.pyx with a PicklableFunction? class wrapping interactively defined (simple) functions to make them picklable:
sage: f = lambda x: x^2 sage: loads(dumps(f)) ------------------------------------------------------------ Traceback (most recent call last): File "<ipython console>", line 1, in <module> File "sage_object.pyx", line 792, in sage.structure.sage_object.dumps (sage/structure/sage_object.c:8357) PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed sage: f = PicklableFunction(f) sage: f(3) 9 sage: f == loads(dumps(f)) True
Change History (2)
comment:1 Changed 4 years ago by nthiery
- Owner changed from was to nthiery
comment:2 Changed 20 months ago by nbruin
Note: See
TracTickets for help on using
tickets.
See #11845 for some code in this direction and for warnings why this should never be allowed in "standard" pickles.