This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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 <>
>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).
Date User Action Args
2019-06-12 11:59:49alegonzsetrecipients: + alegonz, steven.daprano, levkivskyi, abarry
2019-06-12 11:59:49alegonzsetmessageid: <>
2019-06-12 11:59:49alegonzlinkissue28869 messages
2019-06-12 11:59:49alegonzcreate