<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Oh, sorry, I missed a step&#8230;&nbsp; You&#8217;ll need to call
ScriptEngine.GetCompilerOptions().&nbsp; Cast that to a PythonCompilerOptions, and
then do options.Module |= ModuleOptions.Optimized;&nbsp; Finally do source.Compile(options)
and then it should give you the optimized code.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>
users-bounces@lists.ironpython.com [mailto:users-bounces@lists.ironpython.com] <b>On
Behalf Of </b>Wilfredo Lugo<br>
<b>Sent:</b> Wednesday, November 12, 2008 11:45 AM<br>
<b>To:</b> Discussion of IronPython<br>
<b>Subject:</b> Re: [IronPython] Performance Issue<o:p></o:p></span></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Thanks!.<o:p></o:p></p>

<div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

<div>

<p class=MsoNormal>I was able to get the default scope from CompiledCode, but I
am still getting the same performance. &nbsp;Here is the latest code :&nbsp;<o:p></o:p></p>

</div>

<div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;static void Main(string[]
args)<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptRuntime
runtime = Python.CreateRuntime();<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptEngine
engine = Python.CreateEngine();<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptSource
source = engine.CreateScriptSourceFromFile(&quot;interpolate.py&quot;);<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;Console.WriteLine(DateTime.Now);<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CompiledCode
compiled = source.Compile();<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;compiled.Execute();<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptScope
scope = compiled.DefaultScope;<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;Microsoft.Func&lt;string, string, string, string, int, int&gt; func =
scope.GetVariable&lt;Microsoft.Func&lt;string, string, string, string, int,
int&gt;&gt;(&quot;interpolate_start&quot;);<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;Console.WriteLine(func(&quot;3-day-data.txt&quot;,
&quot;3-day-output.txt&quot;, &quot;2008-01-01 00:00:21&quot;,&quot;2008-01-03
23:59:08&quot;,60).ToString());<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;Console.WriteLine(DateTime.Now);<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;Console.ReadLine();<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

<div>

<p class=MsoNormal>This is the latest output :<o:p></o:p></p>

</div>

<div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; 11/12/2008 3:13:01 PM<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; WARNING: desired starting time (Tue Jan 01
00:00:21 2008) prior to time of first<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; &nbsp;data point (Tue Jan 01 00:00:32 2008),
current line: 9411<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; &nbsp;series: 3D<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; &nbsp;force==False, exiting..<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; &nbsp;0<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>11/12/2008 3:16:41 PM<o:p></o:p></p>

</div>

</div>

<div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

<div>

<p class=MsoNormal>Is there could be a problem on how I am calling the
interpolation function? &nbsp;I mean from python.exe I do something like this:<o:p></o:p></p>

</div>

<div>

<div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

<div>

<p class=MsoNormal>if __name__ == '__main__':<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; Interpolate('3-day-data.txt',
'3-day-output-original.txt', '2008-01-01 00:00:<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>21', '2008-01-03 23:59:08', intvl=60, maxgap = 5, stacked =
True, stackedCol = 2<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>, tformat = '%Y-%m-%d %H:%M:%S', debug = False).start()<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

<div>

<p class=MsoNormal>To be able to call the script from the DLR I have something
like this:<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

<div>

<div>

<p class=MsoNormal>def interpolate_start(inFile, outFile, startDate, endDate,
intvl):<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; Interpolate(inFile,
outFile,startDate,endDate,intvl, maxgap = 5, stacked = Tr<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>ue, stackedCol = 2, tformat = '%Y-%m-%d %H:%M:%S', debug =
False).start()<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;&nbsp; return 0<o:p></o:p></p>

</div>

</div>

</div>

<div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

<div>

<p class=MsoNormal>That's the only difference I found on how the script is
called from python and DLR.<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

<div>

<p class=MsoNormal>Any comments?<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

<div>

<p class=MsoNormal>regards,<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

<div>

<p class=MsoNormal>wilfredo<o:p></o:p></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<div>

<p class=MsoNormal>On Wed, Nov 12, 2008 at 2:56 PM, Dino Viehland &lt;<a
href="mailto:dinov@microsoft.com">dinov@microsoft.com</a>&gt; wrote:<o:p></o:p></p>

<div>

<div>

<p><span style='font-size:11.0pt;color:#1F497D'>CompiledCode exposes the
default scope it executes in via the DefaultScope property.&nbsp; So hold onto
the result of source.Compile and after executing the code you can grab the
scope and use it to get your variable.</span><o:p></o:p></p>

<p><span style='font-size:11.0pt;color:#1F497D'>&nbsp;</span><o:p></o:p></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p><b><span style='font-size:10.0pt'>From:</span></b><span style='font-size:
10.0pt'> <a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a>
[mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a>]
<b>On Behalf Of </b>Wilfredo Lugo<br>
<b>Sent:</b> Wednesday, November 12, 2008 10:25 AM<br>
<b>To:</b> Discussion of IronPython<o:p></o:p></span></p>

<div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt'><br>
<b>Subject:</b> Re: [IronPython] Performance Issue<o:p></o:p></span></p>

</div>

</div>

</div>

<div>

<div>

<p>&nbsp;<o:p></o:p></p>

<p>Thanks.<o:p></o:p></p>

<div>

<p>&nbsp;<o:p></o:p></p>

</div>

<div>

<p>But then If I don't use my defined scope, how I could fill my function
delegate?<o:p></o:p></p>

</div>

<div>

<p>&nbsp;<o:p></o:p></p>

</div>

<div>

<p>Right now I am using :&nbsp;<o:p></o:p></p>

</div>

<div>

<p>&nbsp;<o:p></o:p></p>

</div>

<div>

<p>Microsoft.Func&lt;string, string, string, string, int, int&gt; func =
scope.GetVariable&lt;Microsoft.Func&lt;string, string, string, string, int,
int&gt;&gt;(&quot;interpolate_start&quot;);<o:p></o:p></p>

</div>

<div>

<p>&nbsp;<o:p></o:p></p>

</div>

<div>

<p>If I use engine.GetVariables&lt;Func&lt;....&gt;() I still need to pass a
ScriptScope to it. &nbsp;How do I get the default scope (from ScriptEngine or
ScriptSource) to be able to get the delegate?<o:p></o:p></p>

</div>

<div>

<p>&nbsp;<o:p></o:p></p>

</div>

<div>

<p>regards,<o:p></o:p></p>

</div>

<div>

<p>&nbsp;<o:p></o:p></p>

</div>

<div>

<p style='margin-bottom:12.0pt'>wilfredo<o:p></o:p></p>

<div>

<p>On Wed, Nov 12, 2008 at 2:01 PM, Dino Viehland &lt;<a
href="mailto:dinov@microsoft.com" target="_blank">dinov@microsoft.com</a>&gt;
wrote:<o:p></o:p></p>

<div>

<div>

<p><span style='font-size:11.0pt;color:#1F497D'>Instead of doing:</span><o:p></o:p></p>

<div>

<p><span style='font-size:11.0pt;color:#1F497D'>&nbsp;</span><o:p></o:p></p>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptScope scope =
engine.CreateScope();<o:p></o:p></p>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;Console.WriteLine(DateTime.Now);<o:p></o:p></p>

<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;source.Execute(scope);<o:p></o:p></p>

<p><span style='font-size:11.0pt;color:#1F497D'>&nbsp;</span><o:p></o:p></p>

</div>

<p><span style='font-size:11.0pt;color:#1F497D'>do:</span><o:p></o:p></p>

<p><span style='font-size:11.0pt;color:#1F497D'>&nbsp;</span><o:p></o:p></p>

<p><span style='font-size:11.0pt;color:#1F497D'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
source.Compile().Execute()</span><o:p></o:p></p>

<p><span style='font-size:11.0pt;color:#1F497D'>&nbsp;</span><o:p></o:p></p>

<p><span style='font-size:11.0pt;color:#1F497D'>and your code should then run
in an optimized default scope for the code &#8211; just like it does at the command
line.</span><o:p></o:p></p>

<p><span style='font-size:11.0pt;color:#1F497D'>&nbsp;</span><o:p></o:p></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p><b><span style='font-size:10.0pt'>From:</span></b><span style='font-size:
10.0pt'> <a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a>
[mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a>]
<b>On Behalf Of </b>Wilfredo Lugo<br>
<b>Sent:</b> Wednesday, November 12, 2008 9:29 AM<br>
<b>To:</b> <a href="mailto:users@lists.ironpython.com" target="_blank">users@lists.ironpython.com</a><br>
<b>Subject:</b> Re: [IronPython] Performance Issue</span><o:p></o:p></p>

</div>

<div>

<div>

<p>&nbsp;<o:p></o:p></p>

<p>&nbsp;<o:p></o:p></p>

<div>

<p>I run the script directly from ipy.exe and it basically behaves pretty
similar to python.exe (it always took one second more, but I could live with
that). &nbsp;Here is the output:&nbsp;<o:p></o:p></p>

</div>

<div>

<div>

<p>&nbsp;<o:p></o:p></p>

</div>

<div>

<p>$ date +%M:%S;./ipy.exe interpolate.py;date +%M:%S<o:p></o:p></p>

</div>

<div>

<p>17:36<o:p></o:p></p>

</div>

<div>

<p>WARNING: desired starting time (Tue Jan 01 00:00:21 2008) prior to time of
first<o:p></o:p></p>

</div>

<div>

<p>&nbsp;data point (Tue Jan 01 00:00:32 2008), current line: 9411<o:p></o:p></p>

</div>

<div>

<p>&nbsp;series: 3D<o:p></o:p></p>

</div>

<div>

<p>force==False, exiting..<o:p></o:p></p>

</div>

<div>

<p>17:41<o:p></o:p></p>

</div>

<div>

<p>&nbsp;<o:p></o:p></p>

</div>

<div>

<p>So, the problem is on the DLR side. &nbsp;Any clues?<o:p></o:p></p>

</div>

<div>

<p>&nbsp;<o:p></o:p></p>

</div>

<div>

<p>-------------------------------------------------------------------------<o:p></o:p></p>

</div>

<div>

<p>How does python.exe compare directly to ipy.exe?&nbsp; That is, try running
&quot;date +%M:%S;ipy.exe interpolate.py;date +%M:%S&quot; instead of using the
DLR hosting APIs.<o:p></o:p></p>

</div>

<div><pre>Thanks,<o:p></o:p></pre><pre>&nbsp;<o:p></o:p></pre><pre>Dave<o:p></o:p></pre><pre>From: <a
href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com"
target="_blank">users-bounces at lists.ironpython.com</a> [mailto:<a
href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com"
target="_blank">users-bounces at lists.ironpython.com</a>] On Behalf Of Wilfredo Lugo<o:p></o:p></pre><pre>Sent: Wednesday, November 12, 2008 8:32 AM<o:p></o:p></pre><pre>To: <a
href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com"
target="_blank">users at lists.ironpython.com</a><o:p></o:p></pre><pre>Subject: [IronPython] Performance Issue<o:p></o:p></pre></div>

</div>

</div>

</div>

</div>

</div>

<p style='margin-bottom:12.0pt'><br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com"
target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><o:p></o:p></p>

</div>

<p>&nbsp;<o:p></o:p></p>

</div>

</div>

</div>

</div>

</div>

<p class=MsoNormal style='margin-bottom:12.0pt'><br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com"
target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><o:p></o:p></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</div>

</body>

</html>