Giter Club home page Giter Club logo

Comments (5)

DrXyzzy avatar DrXyzzy commented on May 16, 2024

Problem occurs with functions and classes defined at top level in worksheet as well as loaded from file:

function:

import pickle
def f():
    pass
s = pickle.dumps(f, protocol = 2)
==>
PicklingError: Can't pickle <function f at 0x7f1ebb091500>: it's not found as __main__.f

class:

class Klas():
    def kf():
        pass
sk = pickle.dumps(Klas, protocol = 2)
==>
PicklingError: Can't pickle <class __builtin__.Klas at 0x7f1eba3e1a10>: it's not found as __builtin__.Klas

from cocalc.

DrXyzzy avatar DrXyzzy commented on May 16, 2024

WON'T FIX.

Decided not to deploy a fix for this problem, because there is negligible value to saving/pickling a top-level function or class definition at the cost of complexity added. See last few paragraphs here: What can be pickled and unpickled?

A workaround function to save a function or class at top level is here, in case it is needed in some edge case:
76c386b

from cocalc.

haraldschilly avatar haraldschilly commented on May 16, 2024

Despite the "wont fix", I'm reopening this. It's unexpected "buggy" behavior, and it's 100% caused by the sagews layer.

Dear future reader: you can use a jupyter sage kernel talking "more directly" with sage. then this works.

from cocalc.

DrXyzzy avatar DrXyzzy commented on May 16, 2024

@haraldschilly:

Comment from @williamstein on 2016-07-22 was that the proposed fix was not useful in any real-life situation and should therefore be reverted. So I think we have working code, the decision was whether to deploy it.

from cocalc.

williamstein avatar williamstein commented on May 16, 2024

Obviously we aren't fixing this and nobody else complained in 8 years. So closing again.

from cocalc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.