C++ objects into python?


#1

We have our own custom text serialization format for game objects.
I’d like to somehow parse this format into python dictionaries.
(I’ve been playing around with pyparsing with some success, but it is a slog.)

The engine already has a c++ library for parsing the serialized text and generating c++ objects.
It occurs to me that it may be smarter to hijack the existing c++ code
And somehow extract python dictionaries or objects from the c++ objects
But the linking of c++ to Python is new territorty for me and I am unsure how best to proceed.

Has anyone tackled similar problems?


#2

You can try Cython it is a python superset that allows you to generate C/C++ bindings.

PyBind11 is another option, but seems more geared for C++ programmers.


#3

So, I did not see why you’re using Python but can you switch to the C++ API and just build a plugin that way? Just bind directly to CLI.

If that’s not what you want to do you can always also look into OpenMaya for python and use the API directly that way. I used to create all my tools in python but since switched to the C++ API.