Occasionally web2py has been criticized for using exec/execfile instead of import/reload for executing models and controllers. We argue that the web2py method is better for two reasons:
The test code:
import time
open('a.py','w').write('a=True')
import a
t0=time.time()
for i in range(10000): reload(a)
print time.time()-t0
t0=time.time()
for i in range(10000): execfile('a.py',{},{})
print time.time()-t0
Output:
3.61529898643
0.616114854813
Platform:
Intel Macbook (2GHz CPU + 2GB Ram)
Python 2.5.1