Home » Community » Coffee corner » Python for your applications
Python for your applications [message #19670] |
Sun, 04 January 2009 00:31 |
bytefield
Messages: 210 Registered: December 2007
|
Experienced Member |
|
|
Hello,
I was thinking to use python with c++ programs, so I could benefit from python as scripting language, unicode support, sockets, etc.
I've tried some small test to see how python work with. Python 2.5.2 filled my 3 Gigs of memory in seconds and also 500 Mb from swap until i've killed it. With python 3 it finished the execution using just 2.5 MB of memory but it's time is not what i want .
Python time | can@can-laptop:~$ time ./pytest.py
real 6m38.723s
user 6m28.628s
sys 0m0.600s
|
C++ time | can@can-laptop:~$ time ./cpptest
real 0m4.837s
user 0m4.696s
sys 0m0.020s
|
#!/usr/bin/env python3
# pytest.py
def fun(x):
return x + 1
for x in range(0,1000000000):
y = fun(x)
// cpptest.cpp
int fun(int x)
{
return x + 1;
}
int main()
{
for(int y, x = 0; x < 1000000000; x++)
y = fun(x);
return 0;
}
So, now after seeing those results i'm thinking not to use python embed in application. I'm curious what will be the results for usc? Hope better
P.S.: I think the test are right, i've tried to not let C++ compiler to optimize it. If someone can provide other test which prove that python is though good as scripting side of a application please post them and try to convince me about the reality
cdabbd745f1234c2751ee1f932d1dd75
|
|
|
Goto Forum:
Current Time: Fri Mar 29 16:51:38 CET 2024
Total time taken to generate the page: 0.01138 seconds
|