简体   繁体   English

boost python 中的 enable_pickling 和 pickle_suite 有什么区别?

[英]What is the difference between enable_pickling and pickle_suite in boost python?

I have a pretty big class that has ~40 attributes, but only 15 that are passed as arguments to the constructor:我有一个相当大的 class 有大约 40 个属性,但只有 15 个作为 arguments 传递给构造函数:

class MyClass{
    /*40 attributes here*/
    MyClass(/*15 args here, the rest are initialized at default values*/);
};

I'm trying to implement pickle support for this class, and so far the boost.python documentation seems to indicate that I can either implement an instance of the pickle_suite class, or I can just do .enable_pickling() and let python handle the rest. I'm trying to implement pickle support for this class, and so far the boost.python documentation seems to indicate that I can either implement an instance of the pickle_suite class, or I can just do .enable_pickling() and let python handle the rest . Is there any advantage in taking the time to implement all the __getinitargs__ and stuff compared to just doing it with one line?与仅使用一行代码相比,花时间实现所有__getinitargs__和其他东西有什么优势吗? As far as I understand, pickling is essentially converting the objects to a bunch of 1s and 0s and passing it around.据我了解,酸洗本质上是将对象转换为一堆 1 和 0 并传递它。

thanks谢谢

Nevermind, looks like the normal python pickler can't copy the elements inside a container like a std::vector or a std::pair没关系,看起来普通的 python pickler 无法复制容器内的元素,如 std::vector 或 std::pair

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM