From: Patrick C. <pat...@nt...> - 2003-01-26 11:46:26
|
Hi If this is not the right place to ask this question, please accept my appolgies and kindly point me in the right direction. I've tried searching comp.lang.python and general Googling without success. My question is: Is there a big performance problem printing to a file from Jython using the simple print >> file, expression syntax? Or have a made a dumb newbie blunder? The background is: I've been experimenting with using Jython to experiment with extracting data from a number of databases and printing the results in csv format to a file. Jython has made it very easy to quickly write something using the Java libraries I already have access to. I was so impressed I wanted to recommend using the Jython code itself in production, but I have hit a problem when printing to a file from Jython. I'm typically printing 10,000 rows to a file, with some reformatting. Trying to narrow the problem down, I've now eliminated everything from the code except the printing to file part. Stripped right down the code is trivial ... file = open ("PrintTest.txt",'w') item = "some, comma, separated, values" for i in range (10000): print >> file, item file.close() In Jython this is running painfully slowly. For example On Win2K/Pentium3/256MB/Java 1.4/Jython 2.1 this is taking about 5 minutes, there's heavy hard disk activity. On the same machine the same code run from Python 2.2 completes in under 1 sec. I tried the same code on Solaris 8 and got a similar dramatic difference between Python and Jython, although a bit less of a difference than on Windows. Thanks in advance Patrick Chamberlain |