Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does PyPy work with NLTK?

Tags:

python

pypy

nltk

Does PyPy work with NLTK, and if so, is there an appreciable performance improvement, say for the bayesian classifier?

While we're at it, do any of the other python environments (shedskin, etc) offer better nlkt performance than cpython?

like image 444
Parand Avatar asked Dec 08 '10 17:12

Parand


People also ask

What packages work with PyPy?

Compatibility: PyPy is highly compatible with existing python code. It supports cffi, cppyy, and can run popular python libraries like twisted, and django. It can also run NumPy, Scikit-learn and more via a c-extension compatibility layer.

Why is PyPy not used?

It Doesn't Work Well With C Extensions PyPy works best with pure Python applications. Whenever you use a C extension module, it runs much slower than in CPython. The reason is that PyPy can't optimize C extension modules since they're not fully supported.

Is Numpy compatible with PyPy?

TL;DR version: you should use numpy. You can install it by doing pypy -m pip install numpy . You might also be interested in using the experimental PyPy binary wheels to save compilation time. The upstream numpy is written in C, and runs under the cpyext compatibility layer.

How do I use PyPy instead of Python?

For Python 2.7, it's just called pypy . For CPython, if you would like to run Python 3 from the terminal, you simply enter the command python3 . To run PyPy, simply issue the command pypy3 . Entering the pypy3 command in the terminal might return the Command 'pypy3' not found message, as shown in the next figure.


1 Answers

At least some of NLTK does work with PyPy and there is some performance gain, according to someone on #pypy on freenode. Have you run any tests? Just download PyPy from pypy.org/download.html and instead of "time python yourscript.py data.txt" type "time pypy yourscript.py data.txt".

like image 73
TryPyPy Avatar answered Sep 26 '22 11:09

TryPyPy