I use Enthought EPD-Free 7.3-1 for a small function, and when I cut / paste into an interactive session (PyLab) and start it, it takes less than a second. When I run the same code from the python probtest.py command line, it takes more than 16 seconds.
I have confirmed that both use the same python environment. Perhaps related (maybe not), but there is no .pyc file in the directory with the .py file ... none of the python scripts I wrote associated the .pyc files. I checked read / write permissions for the folder, used “repair permissions” (Mac OSX-Lion), and uninstalled / reinstalled EPD_Free python, but no luck.
I do not understand what could be the reason. The code I'm using (simple test x number of dice looking for at least sixteen):
import numpy as np import sys def runTest(numDice, numSixes, numThrows = 10000): nSuccess = 0 for i in range(numThrows): dList = np.random.randint(1,7,numDice) if sum(dList==6) >= numSixes: nSuccess += 1 return float(nSuccess)/numThrows print runTest(900,150,5000) print sys.version
Any thoughts on why the python command line is much slower? Thanks in advance.
Ken l
source share