Python 调用Lua
lupa将Lua和LuaJIT2集成进CPython,可以在Python中执行Lua代码.
Lupa的主要特点:
- separate Lua runtime states through a LuaRuntime class
- Python coroutine wrapper for Lua coroutines
- iteration support for Python objects in Lua and Lua objects in Python
- proper encoding and decoding of strings (configurable per runtime, UTF-8 by default)
- frees the GIL and supports threading in separate runtimes when calling into Lua解决了GIL问题,支持多线程
- tested with Python 2.6/3.2 and later 适用于Python 2.6/3.2以后的版本
- written for LuaJIT2 (tested with LuaJIT 2.0.2), but also works with the normal Lua interpreter (5.1 and 5.2)
- easy to hack on and extend as it is written in Cython, not C 扩展性好
1. lupa安装
这里基于Ubuntu14.04.
lupa官网提供的教程:
# ForDebian/Ubuntu + Lua 5.2
sudo apt-get install liblua5.2-dev # Install Lua 5.2 development package
sudo pip install lupa # Install lupa
<