top | item 2900172

PyPy 1.6 Released - Full Python 2.7.1 Implementation

244 points| jparise | 14 years ago |morepypy.blogspot.com | reply

54 comments

order
[+] lliiffee|14 years ago|reply
Can I take advantage of this thread to ask the HN crowd a technical question? Some time ago, I implemented an automatic differentiation tool. Using operator overloading on a special "autodouble" type the tool would trace the execution of a block of numerical code. Then, some calculus would automatically happen, and it would output and compile fast c-code that would compute the original function and derivatives in pure c. This was great, except the c-code that was output was freaking gigantic (like hundreds or thousands of megabytes) albeit very simple, and so the c compiler would take forever to run. Sigh.

My question is: could I leverage pypy somehow to avoid this? Can I output RPython? Can I output whatever RPython is compiled down to instead? Can I do this with no more than, say, a 3x penalty compared to c?

(I apologize for asking a question only marginally related to the particular article here...)

[+] carterschonwald|14 years ago|reply
Off hand and guessing about the problem:

You might want to look at approaches that use dual numbers. Likewise, in instead of inlining the procedures, generate a differentiated version of each procedure with a new name. If those don't cover your problems, perhaps look at how other autodiff tools for C do it?

[+] beambot|14 years ago|reply
Theano (http://deeplearning.net/software/theano/introduction.html) might be worth a shot if you have closed-form expressions.

'''Theano is a Python library that lets you to define, optimize, and evaluate mathematical expressions, especially ones with multi-dimensional arrays (numpy.ndarray). Using Theano it is possible to attain speeds rivaling hand-crafted C implementations for problems involving large amounts of data. It can also surpass C on a CPU by many orders of magnitude by taking advantage of recent GPUs.'''

[+] ori_b|14 years ago|reply
RPython compiles down to C. Also, do you have an example of the generated code? I'm not sure what sorts of patterns would need it to be hundreds of megabytes.

(Also, if Pypy's compilation time is any guide, it takes massive amounts of time to compile rpython)

[+] sjs|14 years ago|reply
LLVM? I don't have much experience with runtime code generation but you might find it useful.
[+] voyvf|14 years ago|reply
> has beta level support for loading CPython C extensions.

Is this via ctypes, or "real" support in much the same as how CPython would behave?

I ask because this is one of the features that I've been waiting (impatiently) for - I've run some Flask projects using PyPy and gunicorn, and love how fast it goes, but really want to be able to use the rest of my codebase, which unfortunately does rely on some C (and Cython) extensions. (:

[+] vgnet|14 years ago|reply
It's "real" support, using your criteria. However, it's slower in PyPy than in CPython and than what the same thing based on ctypes would be on PyPy.

If there's a pure-Python version of the C extension, it might be faster on PyPy than the C extension support that cpyext (PyPy C-API compatibility module) provides.

Cython-based code is currently incompatible (it goes well beyond the public C-API), but a GSoC project to generate ctypes-based pure-Python code from Cython is (was?) going on.

[+] pjenvey|14 years ago|reply
Not via ctypes, via CPyExt, a layer emulating the CPython C extension API (it actually implements a reference counting GC and everything)
[+] sylvinus|14 years ago|reply
I'm always blown away by the consistent performance gains they reach with each new version. Congrats!
[+] kristofferR|14 years ago|reply
In general I'm very happy with my choice of Ruby/Rails instead of Python/Django, but PyPy is one of the few things I envy Python developers for.

I wish something similar could be developed for Ruby.

[+] sirn|14 years ago|reply
What about Rubinius?

Can you also elaborate on why you're happier with Ruby and Rails than Python and Django. Since I'm completely the other way around, while Ruby paid my bills, if there's a Python job offering I would have jumped onto it without much thought.

One of few things I envy Ruby developers for is the HAML, SCSS, Jammit stuff. Apart from that, not so much, especially for documentations for Ruby modules. It might be from the fact that I prefers Flask[1] to Django, but I also like Python's explicitness than Ruby's implicit and found Python language design to better suits my taste (e.g. the Python class[1]).

[1]: http://lucumr.pocoo.org/2011/7/9/python-and-pola/

[2]: http://flask.pocoo.org/

[+] Freaky|14 years ago|reply
If it's mainly the performance you're after, have a look at JRuby. It's already a decent chunk faster than MRI/YARV, and with Java 7 and invokedynamic there's a lot more to look forward to and play with now.

Last week one of the JRuby core devs tweeted: "Ok, another set of tweaks in JRuby and fib(35) is another 10% faster (and only about 10% slower than Java. Do I stop now?"

[+] irahul|14 years ago|reply
> but PyPy is one of the few things I envy Python developers for.

Depending on your needs, there are others - numpy, scipy, matplotlib, nltk, gevent.

> I wish something similar could be developed for Ruby.

Isn't http://rubini.us/ supposed to be the PyPy for Ruby? It's not complete, but then neither is PyPy.

[+] sho_hn|14 years ago|reply
I'm still bummed at being stuck with the dilemma of having to chose between CPython 3.x and PyPy. PyPy with Py3k support would rock.
[+] socratic|14 years ago|reply
Are there production users of PyPy?

I feel like PyPy has always been the most academically interesting Python implementation. But has it taken away mindshare from CPython?

[+] vgnet|14 years ago|reply
Yes, there are.

Recently Quora announced it was running on PyPy[1]. Some other disclosures were made (a Django project[2], LWN internal processing[3], tweets about speedups in production, etc.), but the PyPy team is thinking about officially asking for success stories in the near future[4].

[1]: http://www.quora.com/Alex-Gaynor/Quora-product/Quora-is-now-...

[2]: https://convore.com/python/whos-using-pypy-in-production/

[3]: http://lwn.net/Articles/442268/

[4]: https://bitbucket.org/pypy/extradoc/src/tip/blog/draft/succe...