How can I create a language independent library using Python?

后端 未结 7 1754
夕颜
夕颜 2021-01-11 10:51

If I create a package in Python, then another Python user can import that package and interface with it.

How can I create a package so that it doesn\'t matter what l

7条回答
  •  孤城傲影
    2021-01-11 11:02

    If you want another language to be able to use your library directly (not using any kind of remote service or IPC stuff which is a whole different kettle of fish), you need to write language bindings for it, meaning there is a layer they call in the target language that calls your package under the hood. There are various toolkits for creating this, but it's usually the kind of thing you do if you want to be able to call a C or C++ library from a higher level scripting language like Python. For example, in C there exists the SWIG project to help make it possible to call C from Python, PHP, Ruby, etc.

    This page will give you a bunch of intro links, it's a big and hard topic to be honest. I've only done it from C to Python myself. https://wiki.python.org/moin/IntegratingPythonWithOtherLanguages

提交回复
热议问题