加速Python运行的工具应用

如果你需要让你的Python程序加速运行,在不同的层次有一些不同的解决方案:

 

  1. 重写 你的 Python 代码, 通过 并行化parallelizing 和 优化optimizing/替代replacing/调试tuning 运算方法,比如使用: 
    • Hadoop 或者 Disco
      •  MapReduce 的开源实现工具
    • Parallel Python Python 并行运算
    • Message Passing Interface (MPI)
      • 经常用于大量数学运算
    • Bulk Synchronous Parallel (BSP) 
    • RPyC
      • 针对分布式/并行程序的RPC
    • Twisted
      • 用于分布式/并行程序的网络库
    • Profiling Tools
    • 线程 thread或者 Microthreads (Stackless) 
  2. 使用工具加速你的代码而不需要大量修改
    • Psyco
      • Just in time JIT 编译器,注意这是最容易使用的实现方式。
    • Pyrex
      • 写和编译Python,通过近似 C 风格的数据结构
    • Cython 
    • PyJs 
      • 编译 (大子集) Python 为 Javascript, 注意:这更适合于客户端编程比如ajax,而非服务器端。
    • Rpython
      • 编译 (大子集) Python 为本地代码,注意:这是 PyPy 项目的一部分。
    • Shedskin 
      • 编译 (大子集) Python 为 C++,这是一些测试结果: some benchmarks
  3. 替换 (一部分) 你的 Python 代码 为其他语言
    • Simplified Wrapper and Interface Generator (SWIG) 
      • Use C/C++ from Python
    • Fortran to Python Interface Generator (F2PY) 
      • Use Fortran from Python
    • llvm-py 
      • 编写代码和编译为汇编语言,用于运行在底层虚拟机上。
    • CorePy 
      • 在Python中写汇编代码
    • Weave 
    • PyInline 
    • Boost.Python
    • Cinpy 
      • cinpy模块利用tcc混合C代码和Python(使用ctypes)在运行时刻编译成为可执行代码

 

你可能感兴趣的:(加速Python运行的工具应用)