Unfortunately import speed is one of the areas where CPython is drastically faster than IronPython. The primary reason for this is that we will compile all the modules that get imported during importation which slows things down.
One possible work around is to use the pyc tutorial although that's known to not work with packages. Also you can vote on this bug (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=358) which will enable us caching the modules on disk (like CPython caches .pyc files) so that import time will be greatly improved. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of illium Sent: Monday, January 08, 2007 2:35 PM To: [email protected] Subject: [IronPython] IronPython vs Cpython import speeds. Hi, I'm in the process of porting a project from CPython to IronPython. This is my first time using IronPython, so I'm not completely sure what to expect. After getting over the inital configuration hurdles, I got my program to execute normally within IronPython, and moved on to performance testing, attempting to feel all warm and fuzzy about how much faster my code was running in shiny new IronPtyhon. However, I immediately noticed a major difference, to the worse, in speed performance between the two engines. In order to isolate the problem I started adding time stamp traces into the code, and found that the majority of the perfomance loss was occuring during import calls. So I made this little test file, importspeedtest.py: import time print time.time() import sys, os, string, re print time.time() Then made this little batch file to compare them... importspeedtest.bat: @echo IronPython @echo ---------- @echo %time% @c:\IronPython\ipy.exe c:\PythonSourceFiles\importspeedtest.py @echo %time% @echo ---------- @echo Python 2.5 @echo ---------- @echo %time% @c:\Python25\python.exe c:\PythonSourceFiles\importspeedtest.py @echo %time% @echo ---------- The results: IronPython ---------- 14:23:55.09 63303863036.3 63303863037.5 14:23:57.73 ---------- Python 2.5 ---------- 14:23:57.80 1168295037.9 1168295037.91 14:23:57.91 ---------- The total execution time in IronPython was 2.64 seconds, and in CPython was .09 seconds. The amount of time to execute the line "import sys, os, string, re" in IronPython was 1.2 seconds, and in CPython .01 seconds. In actual use in my project I found that start to finish, with the overhead of launching the embedded engine, loading and executeing the source file, doing the processing on my sample data, and exiting, using IronPython it took 5 seconds, with 2 seconds of that time being the import calls, while the same process/code using Python 2.5 completed in only 1.5 seconds round trip, with .02 seconds used for the import calls. So.. on to my question: Is this normal, or am I doing something wrong? Is there a way to optimize my code for faster loading in IronPython? Any assistance/insight would be greatly appreciated, as I really want to move over to IronPython, so that I can embedd it into my c# app, instead of calling it via the commandline as I'm currently doing with CPython. But this kind of performance loss makes it unusable at the moment. Thanks, Troy Howard __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com _______________________________________________ users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
