[IronPython] Performances and Profiling of ReportLab under IronPython

Marco Parenzan marco.parenzan at libero.it
Thu Aug 20 17:18:27 CEST 2009


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?





More information about the Ironpython-users mailing list