I'm trying to run a Python script from PHP on a webserver. The script only contains one line
print "Hello, World"
and if I run it from the terminal, it takes 0.028 seconds. When I try doing this from PHP though
exec('python python_test.py');
it takes 125 seconds (but it does execute the script in the end). I read that there is an overhead because a new shell instance needs to be created whenever exec is called from php (PHP exec() performance), but that's not the problem since when I ran:
exec('echo hi');
it only took 0.013 seconds. So it's really the Python script that is running very slow. Any thoughts on how to make it faster?
I also tried the PHP commands shell_exec() and system() but they don't improve the speed.