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

Class attributes added at initialization of an instance are not serialized #215

Closed
edwardreed81 opened this issue Mar 13, 2017 · 2 comments
Milestone

Comments

@edwardreed81
Copy link

This comes from a stackoverflow question: http://stackoverflow.com/questions/42752716/how-to-write-all-class-variables-to-disk-with-dill

If one were to change a class attribute during initialization of an instance of that class, dill does not serialize this class attribute.

That to me screams bad coding practice... however, a serializer shouldn't be judgmental, and should handle it.

I tried doing this through something like

class Basic(object):
    x = 10
    def __init__(self, initial=False):
        super(Basic, self).__init__()
        self.y = 4
        Basic.z = 5

as well as using a metaclass with a custom __call__ to set the class attribute. Both do not serialize properly.

@matsjoyce
Copy link
Contributor

See #47. We were discussing this problem, but is kind of got abandoned. @mmckerns do we want to have another go at this?

@mmckerns
Copy link
Member

mmckerns commented Mar 13, 2017

@matsjoyce: I think actually, the better reference is issue #42. Yeah, I have a small collection of tickets that we should sort out, and this is one of them (#42 and associated tickets). Let's try to sort it.

@edwardreed81: I appreciate the ticket, and it is totally a valid issue… however I am closing this ticket as a duplicate of #42. We likely will, however, use the above code as a test case for #42 as well as some motivation to unstick an old issue. Can you please detail here an example of the custom __call__ method, so we can clearly see what you are looking for?

@mmckerns mmckerns modified the milestone: dill-0.2.7 Jul 8, 2017
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