I would like to call Python's pickling routines (dumps
and loads
) from within c++ code. Are they exposed in the official API? I am currently calling those via boost::python from c++, looking for a simpler way perhaps.
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
You can call any Python code through the C API:
now, you can either call it like:
python-2.x
python-3.x
or like:
and then do the error checking and clean up:
but in the case of
pickle
you can just use thecPickle
functions directly. The only problem there is that thecPickle
module (or_pickle
in Python 3) is statically compiled into the Python binary, or needs to be loaded separately. Using the Python import mechanisms is simply easier here.