On 10/30/2012 11:19 AM, Sasikanth Eda wrote:
I have tried to perform a CPU intensive operation ( which typically
involved calculation of prime numbers from 1-100000 ) using
Multi-process and Multi-Thread models provided by
C, Python-2.6, PyPy-1.9.
Note that your code is very slow. I can find all primes up to 100000 in
less than 0.3s in CPython and less than 0.2s in PyPy, using a single
process with a single thread.
*/{ Here I came to a conclusion that Python is limited by the Global
Interpreter Look (GIL) when used in Multi-Thread mode (that is why it
gave poor results when compared with process model }/*
Yes.
*{ /Here I came to a conclusion that PyPy is better than Python }/*
Yes, PyPy is faster than CPython for most (not all!) Python programs.
1. Has PyPy optimized / reduced the GIL limitation ? ( what is the
progress in PyPy version 1.9 in that when compared with Python's progress )
2. If PyPy is also suffering from the same GIL limitations, what made
the program run faster than Python, is it because of
more warm-up time, optimization of loops ?
PyPy has a Just In Time (JIT) compiler that compiles hot loops to
machine language.
3. What are your suggestions for me if I wanted to go for
Multi-Thread application design ( in-terms of Python / PyPy )
For now, you will not be happy with multiple CPU-bound threads in
CPython or PyPy, because of the GIL. Jython is free-threaded but is
slow in other ways. If you insist on using threads for CPU-bound work,
you will probably be happier with another language.
However, Armin Rigo is working on Software Transactional Memory for
PyPy, which may someday end up making multi-threaded code fast. Web
search for "pypy stm" to find details.
--
David Ripton [email protected]
_______________________________________________
pypy-dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-dev