3

I have a very large heterogeneous Python codebase that uses Django as the front-end. This codebase is deployed alongside several servers that are beginning to show the strain and we're looking for ways to speed things up while we re-architect the codebase, and to keep the new code running fast.

We're currently looking at Pypy but it seems a bit iffy. It has many limitations and requires refactoring a lot of code (can't concatenate strings with "+"?).

Does anyone have experience with it? Are there any large scale websites using it?

ruipacheco
  • 15,025
  • 19
  • 82
  • 138
  • 1
    `› pypy` `Python 2.7.3 (2.2.1+dfsg-1ubuntu0.2, Dec 02 2014, 23:00:55) [PyPy 2.2.1 with GCC 4.8.2] on linux2` ... `>>>> "a"+"b"` `'ab'`. Seems to work for me – Tom Dalton Sep 30 '15 at 08:58
  • Have you profiled the code at all? I wouldn't expect moving to Pypy to *necessarily* be much less work than reworking the slow parts of the code. I guess it depends how good your test coverage is and whether bugs etc are acceptable to you. – Tom Dalton Sep 30 '15 at 09:00
  • It works, it's just slower than CPython. – ruipacheco Sep 30 '15 at 13:28
  • This is not opinion-based and should never have been closed. We can disambiguate 'big project' by specifying minimum number of users, website visitors or Github stars. – smci Apr 22 '17 at 11:58

1 Answers1

4

Migration from CPython to PyPy is the last thing you should consider when thinking about web site performance (after architecture, database, caching, distributed queues, etc.). And if you absolutely need code-level optimizations (as shown by thorough profiling), then consider going straight to C/C++ for ultimate speed.

PyPy is mostly compatible with CPython on language and standard library level, but it's incompatible with many CPython C extensions (and the compatible ones may actually work slower). If your site is pure Python and has proper test coverage, you can easily check if it works with PyPy and if it's considerably faster or not. If you don't have tests, things are getting risky. If you use C extensions, you'll face issues and it's likely more trouble than it's worth.

See also:

Community
  • 1
  • 1
alexanderlukanin13
  • 4,577
  • 26
  • 29
  • 6
    your comment is factually incorrect - there are large sites using pypy (most of them I'm not allowed to talk about), however porting to C/C++ of a medium size django application is just a no-no. Noone will do this. – fijal Oct 09 '15 at 12:01