Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

cpython compilation parameter

0 views
Skip to first unread message

cEd

unread,
Oct 8, 2009, 9:34:39 AM10/8/09
to
Hello,

I'm wondering how to compile python to get good performance.
Because when I compare this ugly code which find prime number:

# prime_number.py
start=30000
for is_first in range(start):
found = 0
is_first+=1
for i in range (2, is_first):
if not (is_first%(i)):
found = 1
break
if not found:
print is_first


between :
- the python distributed with my ubuntu
#time python prime_number.py > /dev/null
real 0m12.237s
user 0m12.129s
sys 0m0.024s

- and the one compiled by my self
time my_python_compiled prime_number.py > /dev/null
real 0m42.193s
user 0m41.891s
sys 0m0.044s

so which option should I give or which flag ???

regards

cEd

Diez B. Roggisch

unread,
Oct 8, 2009, 9:39:13 AM10/8/09
to
cEd wrote:

I doubt that there is such a flag. There must be a different reason for
this. Can you give us the python versions for each, and architecture (32/64
bit)?

Diez

Jorgen Grahn

unread,
Oct 14, 2009, 9:13:01 AM10/14/09
to
On Thu, 2009-10-08, Diez B. Roggisch wrote:
> cEd wrote:
>
>> Hello,
>>
>> I'm wondering how to compile python to get good performance.
>> Because when I compare this ugly code which find prime number:

...

>> between :
>> - the python distributed with my ubuntu
>> #time python prime_number.py > /dev/null
>> real 0m12.237s
>> user 0m12.129s
>> sys 0m0.024s
>>
>> - and the one compiled by my self
>> time my_python_compiled prime_number.py > /dev/null
>> real 0m42.193s
>> user 0m41.891s
>> sys 0m0.044s
>>
>> so which option should I give or which flag ???
>
> I doubt that there is such a flag. There must be a different reason for
> this. Can you give us the python versions for each, and architecture (32/64
> bit)?

He could start by compiling it exactly like Ubuntu does. Just get the
Ubuntu source packet -- it's all in there, Ubuntu doesn't keep it a
secret.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .

0 new messages