mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-11 16:13:53 +00:00
22 lines
485 B
Python
22 lines
485 B
Python
|
from __future__ import print_function
|
||
|
import sys
|
||
|
|
||
|
sys.path.append('.')
|
||
|
|
||
|
from example import Pickleable
|
||
|
|
||
|
try:
|
||
|
import cPickle as pickle # Use cPickle on Python 2.7
|
||
|
except ImportError:
|
||
|
import pickle
|
||
|
|
||
|
p = Pickleable("test_value")
|
||
|
p.setExtra1(15)
|
||
|
p.setExtra2(48)
|
||
|
|
||
|
data = pickle.dumps(p, -1) # -1 is important (use highest protocol version)
|
||
|
print("%s %i %i" % (p.value(), p.extra1(), p.extra2()))
|
||
|
|
||
|
p2 = pickle.loads(data)
|
||
|
print("%s %i %i" % (p2.value(), p2.extra1(), p2.extra2()))
|