On Wed, 23 Feb 2005, Jacob S. wrote:
> Say I put the code > > import psyco > psyco.full() > > in sitecustomize.py and run a random file that I have already got an > average execution time of. Then I run it again, with the above > implemented. My execution time is has dropped. Which brings me to > believe that psyco monitors all subprocesses and all subobjects. Hi Jacob, Yes, psyco.full() will do so, by patching itself in the Python runtime. But normally, people will run psyco on specific functions that they know are hot-spots in their code by using psyco.bind(). > So this being the case, why haven't the volunteers set up from > __import__ division so that you can put it in sitecustomize.py and get > it to run whenever you start python? One thing is that psyco only works on the x86 platform. It's also a bit experimental; in the Drawbacks section in Psyco's introduction: http://psyco.sourceforge.net/introduction.html the page mentions that the behavior of certain programs will change under Psyco, and that's not ideal. Finally, Psyco uses a lot of memory, and that's probably the biggest drawback. In short, Psyco is intrusive enough that it's probably not a good idea to turn it on by default. > Anyways, this all came up because several modules that used psyco.full() > would greatly be hindered if they imported another module that did the > same. So I got the great idea, why not put it in sitecustomize.py? I think the current thinking is that individual modules are responsible for calling psyco on themselves --- that is, the authors of a module would know best what functions would benefit most from Psyco's JIT compilation. Calling Psyco on everything is probably not a good idea, just because it does use a lot of memory, and because there is a time cost involved in doing the JIT stuff itself. If some code is going to be run just once anyway, there's really not much gain in JIT-ing it first, since all that analysis is probably going to cost more than running the code once. Psyco can work wonders on things like inner loops, but it's not so effective on top-level code. > Then I got the idea, why not put from __import__ division in the > sitecustomize.py, too? psyco.full() worked, from __import__ division > did not. The statement: ### from __future__ import division ### is module specific; it won't automatically affect division throughout the system, but limits itself to the particular module where it's been declared. So in your example, new-style division actually is being turned on only for sitecustomize.py. This is briefly mentioned in: http://www.python.org/peps/pep-0238.html with: """ - The future division statement, spelled "from __future__ import division", will change the / operator to mean true division throughout the module. """ If we want to make new-style division work throughout the system, we can call Python with the '-Q new' command line argument. Best of wishes to you! _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor