Author alegonz
Recipients abarry, alegonz, levkivskyi, steven.daprano
Date 2019-06-12.11:59:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1560340789.92.0.241857511785.issue28869@roundup.psfhosted.org>
In-reply-to
Content
>I think we can proceed with option A, but only if doesn't cause visible slow-down for creating ABCs (which is already slower that normal classes). TBH, I don't want to document A as "official" recipe (maybe however mention the problem in the `pickle` module docs).

I'll try using the same approach used in namedtuple, and see if there is any visible slow-down.

Regarding the documentation, I see your point. Perhaps adding some section like "Notes on pickling dynamically-defined classes" in the `pickle` module would be more appropriate? That section would mention that you have to make sure to set the `__module__` attribute.

>Note that other "class factories" in stdlib (like collections.namedtuple) do almost exactly option A.

Thanks for the tip. Indeed it does. In fact, the API defines a module argument. Its documentation could be improved, though. It should mention why would you want to pass that argument (pickling seems to be the reason that argument was added in the first place).
History
Date User Action Args
2019-06-12 11:59:49alegonzsetrecipients: + alegonz, steven.daprano, levkivskyi, abarry
2019-06-12 11:59:49alegonzsetmessageid: <1560340789.92.0.241857511785.issue28869@roundup.psfhosted.org>
2019-06-12 11:59:49alegonzlinkissue28869 messages
2019-06-12 11:59:49alegonzcreate