[IronPython] Performances and Profiling of ReportLab under IronPython

Dino Viehland dinov at microsoft.com
Thu Aug 20 17:51:38 CEST 2009


IronPython import time remains much slower than CPython.  I think you've seen from the differences between 2.0 and 2.6 that we've already made significant progress in improving this - and we certainly plan to continue pushing on it with each release.

One way to improve startup time today is to use the pyc tool (in Tools\Scripts in the IronPython install) to pre-compile your .py files.


-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Marco Parenzan
Sent: Thursday, August 20, 2009 8:18 AM
To: users at lists.ironpython.com
Subject: Re: [IronPython] Performances and Profiling of ReportLab under IronPython

Curt,

thanks for tip: it's ok. That's the code:

            __pySearchPaths = new
List<string>(Properties.Settings.Default.PySearchPaths.Split(';'));
            __pyEngine = Python.CreateEngine();
            __pyEngine.SetSearchPaths(__pySearchPaths);
            __pyEngine.ImportModule("reportlab.graphics");
            __pyEngine.ImportModule("reportlab.graphics.shapes");

            ScriptScope scope = __pyEngine.CreateScope();

            ScriptWriter writer = new ScriptWriter();
            // an helper class I use to write python code in C# code
            writer.Clear();
            writer.Write("from reportlab.graphics.shapes import Drawing,
String");
            writer.Write("from reportlab.graphics import renderPDF");
            writer.Write("d = Drawing(100, 100)");
            writer.Write("s = String(50, 50, 'Hello world',
textAlign='middle')");
            writer.Write("d.add(s)");
            writer.Write(@"renderPDF.drawToFile(d, 'HW.pdf', 'Hello World
{0}')");
            __pyEngine.Execute(writer.Script(false), scope);

About startup time: yes, the first five lines takes 10/11 seconds!
With your tip I have solved my problem, but I don't understand the
difference between IPY and CPython (1 seconds from start to end).

        Marco

-----Original Message-----
Date: Thu, 20 Aug 2009 07:43:08 -0700
From: Curt Hagenlocher <curt at hagenlocher.org>
To: Discussion of IronPython <users at lists.ironpython.com>
Subject: Re: [IronPython] Performances and Profiling of ReportLab
        under   IronPython
Message-ID:
        <d2155e360908200743u77e7f0feka8ca4ec4f9f0fc76 at mail.gmail.com>
Content-Type: text/plain; charset="windows-1252"

Imports are specific to a ScriptEngine. When you create a new ScriptScope
through the hosting interface and run "import foo" inside of it, the
standard Python behavior applies -- if "foo" is already in sys.modules, it
won't be imported again. Instead, the name will just be added to the current
scope.

When you say "startup time" in this context -- that includes the time it
takes to import the modules?


_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Ironpython-users mailing list