-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigate using PyPy as default python compiler instead of CPython #1728
Comments
Just to be clear, this is an investigation. Closing this ticket will require some performance benchmarks comparing our current compilation vs PyPy compilation. Once benchmarks are posted, we'll continue discussion on the mailing list and decide the way forward. I just don't want someone creating a PR that moves the whole repo to PyPy because it won't get merged until we've all discussed and agreed that it's the best thing. |
Ok. Agreed. |
just a correction, anyway, I think this could be an alternative, maybe not default resolution, so we can experiment, iron out possible incompatibilities and people can run whatever interpreter they prefer. |
Hi @breznak, project names in Python world are really confuse.. hehe.. Actually In other words: pypy was 10x faster than (c)python, not cython. All these confusion in names is because every project founder wants use the Once we talked about PyPy vs Cython, it seems that PyPy is faster than it in several applications, mostly in cases where long-running loops are frequent (https://groups.google.com/forum/#!topic/cython-users/OwAIcJwWH14), which is the case of nupic. The magic of PyPy is that it compile code that is frequently used. Futthermore its compiled code is well optimized. |
@david-ragazzi they should get more creative with the names in python world 😄 |
this will be not so easy as just switching..
^^^ this might be related to using numpy version from git |
Seems this got stucks as |
Good news: Newer versions of PyPy has provided better compatibility with existent python base codes. So these days I decided test pypy and fortunatelly I got (very) excellent performance results to a (very) low price: only 1 or 2 lines in SpatialPooler need be refactored due to a numpy function not ported to pypy (yet). I still didn't test TemporalMemory with pypy but I'm pretty sure that probably few or no lines will need be changed. I'll ellaborate a benchmark more complete these days and present a report with results and potential drawbacks to you check the feasibility. To reinforce the gain with PyPy, look this 2011 article where PyPy beats even C! |
wow @david-ragazzi ! could you share some (performance) results and possibly a branch to try? ;) |
I'm a total nupic newbie, but I have a lot of CPython and some Pypy and Cython. If someone will outline a script (like what to import for the C++ version, what to import for the pure-python version, what to instantiate and call in a loop), I'll excitedly dive into an actual performance comparison. BTW, technically Python is a language, CPython is the reference implementation of the Python language, Pypy is a JIT compiled implementation of Python, and Cython is an AOT compiled dialect of Python that can be quite fast if you give it the right types (but can actually be slower than CPython if you're not careful). Often when people say Python, they mean CPython, but that's becoming less and less appropriate, what with Pypy, Micropython, Jython, IronPython, etcetera. Last I heard, Pypy was able to use nearly all of the official numpy, passing 99.9% of numpy's test suite. However, it uses Pypy's cpyext to call the native code of numpy, which can be a bit slow - so it's only a decent performer for large datastructures like big matrices. |
These days I was reading articles explanning differences between the several derivations of Python world (http://www.toptal.com/python/why-are-there-so-many-pythons, for example) and one of these projects catched my interest.
During my research I read several good things about PyPy, which is not an implementation of Python itself but a JIT (just-in-time) compiler of python code. What really interested me, is that it is able to compile much faster than CPython (the default Python compiler) without many changes in the current code (http://pypy.org/compat.html).
Just look this speed comparison:
http://speed.pypy.org/
According to the benchmarking, code compiled by the current PyPy version is able to run 6.90x faster than code compiled using the default compiler. @breznak also said in ML that his colleague reported that his text processing project was 10x faster using PyPy than CPython.
@scottpurdy suggested we
could try it is with a simple loop that feeds an instance of the CLA classifier. You can then compare speeds for the Python and C++ implementations on both cpython and pypy
.Update
Just to avoid confusion: CPython is not Cython.
cpython
is the our well known Python default compiler (nupic uses the2.7
version, for example) whilecython
(without thep
) is a python-like language that use static typing among other features: http://www.reddit.com/r/Python/comments/23kz8o/cpython_vs_pypy_vs_cython/The text was updated successfully, but these errors were encountered: