Giter Site home page Giter Site logo

Support for pickle and copy about traitlets HOT 5 CLOSED

ipython avatar ipython commented on August 21, 2024
Support for pickle and copy

from traitlets.

Comments (5)

rmorshea avatar rmorshea commented on August 21, 2024

I don't have my computer available so I can't test it, but it seems like pickling for this is already supported since the trait values are stored in _trait_values.

from traitlets.

NeilGirdhar avatar NeilGirdhar commented on August 21, 2024

@rmorshea Oh of course. If a subclass overrides setstate and getstate, they will have to pickle _trait_values themselves. Is that the approach you prefer?

from traitlets.

rmorshea avatar rmorshea commented on August 21, 2024

@NeilGirdhar deleted old comment (couldn't check to see if __dict__ overrided descriptors since my computer's still out of commission). In any case though, going down the route of your example, you'd have to manage pickleability both on state[name] and state['_trait_values'][name] which seems redundant.

However, checking for getstate and setstate methods that control the values in state['_trait_values'] might be something to consider.

from traitlets.

rmorshea avatar rmorshea commented on August 21, 2024

@SylvainCorlay @jasongrout
Would it be worth including getstate(self, obj) and setstate(self, obj, value) methods for TraitTypes whose values are potentially unpicklable that get called in __getstate__ and __setstate__?

from traitlets.

rmorshea avatar rmorshea commented on August 21, 2024

I think we can close this until someone else requests TraitType specific get/setstate methods

from traitlets.

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.