Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement PicklableFunction(interactive_function) #8561

Open
nthiery opened this issue Mar 19, 2010 · 1 comment
Open

Implement PicklableFunction(interactive_function) #8561

nthiery opened this issue Mar 19, 2010 · 1 comment

Comments

@nthiery
Copy link
Contributor

nthiery commented Mar 19, 2010

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

CC: @sagetrac-sage-combinat

Component: pickling

Keywords: lambda, interactively defined functions

Issue created by migration from https://trac.sagemath.org/ticket/8561

@nbruin
Copy link
Contributor

nbruin commented Jan 9, 2013

comment:2

See #11845 for some code in this direction and for warnings why this should never be allowed in "standard" pickles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants