简体   繁体   中英

How to use Nuitka to compile jsonpickle (a Python lib) to C/C++?

I'm using jsonpickle in my program, but found it to be a performance bottleneck. So I'm trying to see if I can compile it to C using Nuitka , then use the C version in my program (through some wrappers perhaps).

But to be honest, I'm new to Nuitka, so I don't even know if this is a legit use case. Can someone give me some hints?

Note: this question is not about how to make a program faster. I'm building a library, not an application, so certain approaches like Pypy won't work. I'm also aware of Cython and is investigating it too, but this question is not about Cython either.

Figured it out myself. Just git clone the repo, go into the directory, and run

python -m nuitka --module jsonpickle --include-package=jsonpickle

Nuitka will generate a .so file, and you can import and use it just like the original package.

This method should be universal and could apply to any package and not just jsonpickle.

Do note that Nuitka is meant to be used in an application, but not good for building a library. The main pain point is that it doesn't support cross-compilation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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