At 03:12 PM 3/11/2008 -0700, Rob Malouf wrote: >On Mar 11, 2008, at 2:57 PM, David MacQuigg wrote: >> I guess what I should conclude is that when performance is >>important, don't bother trying to optimize Python. Go straight to >>C, and get 10 or 100X improvement. > >That hasn't always been my experience. I found that using psyco and >numpy (along with careful profiling and optimization), I can often get >essentially the same performance from pure Python that I can get from >mixed Python/C solutions, and with much less trouble.
I agree that the Python/C interface is more trouble than it should be, especially for freshman engineering students and technical professionals who don't have time for messy programming details. What I would like to see is something like a simple "directive" I could put in my Python code to say "The following function is in C", and have Python set up the linkage for me. It would make a nice improvement in this Mandelbrot demo if you could show me a way to significantly improve the speed of the Python I already have, perhaps avoiding the need for C. I've posted the complete Python module at http://ece.arizona.edu/~edatools/ece175/projects/mandelbrots/mandel.py Just run the command $ python mandel.py and you should see the output from two examples in the doctests: 1a) Python speed = 787 points/sec 1b) C speed = 125500 points/sec 2a) Python speed = 823 points/sec 2b) C speed = 134300 points/sec The C source, mandelbrotC.c, is also in that same directory. The tests above were done on an old Windows machine running Cygwin. -- Dave _______________________________________________ Edu-sig mailing list Edu-sig@python.org http://mail.python.org/mailman/listinfo/edu-sig