Thanks!.<div><br></div><div>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;</div><div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;static void Main(string[] args)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptRuntime runtime = Python.CreateRuntime();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptEngine engine = Python.CreateEngine();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptSource source = engine.CreateScriptSourceFromFile(&quot;interpolate.py&quot;);</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Console.WriteLine(DateTime.Now);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CompiledCode compiled = source.Compile();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;compiled.Execute();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptScope scope = compiled.DefaultScope;</div>
<div>&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;);</div><div>&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());</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Console.WriteLine(DateTime.Now);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Console.ReadLine();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div><br></div><div>This is the latest output :</div><div><div>&nbsp;&nbsp; 11/12/2008 3:13:01 PM</div><div>&nbsp;&nbsp; WARNING: desired starting time (Tue Jan 01 00:00:21 2008) prior to time of first</div>
<div>&nbsp;&nbsp; &nbsp;data point (Tue Jan 01 00:00:32 2008), current line: 9411</div><div>&nbsp;&nbsp; &nbsp;series: 3D</div><div>&nbsp;&nbsp; &nbsp;force==False, exiting..</div><div>&nbsp;&nbsp; &nbsp;0</div><div>11/12/2008 3:16:41 PM</div></div><div><br></div><div>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:</div>
<div><div><br></div><div>if __name__ == &#39;__main__&#39;:</div><div>&nbsp;&nbsp; Interpolate(&#39;3-day-data.txt&#39;, &#39;3-day-output-original.txt&#39;, &#39;2008-01-01 00:00:<br></div><div>21&#39;, &#39;2008-01-03 23:59:08&#39;, intvl=60, maxgap = 5, stacked = True, stackedCol = 2</div>
<div>, tformat = &#39;%Y-%m-%d %H:%M:%S&#39;, debug = False).start()</div><div><br></div><div>To be able to call the script from the DLR I have something like this:</div><div><br></div><div><div>def interpolate_start(inFile, outFile, startDate, endDate, intvl):</div>
<div>&nbsp;&nbsp; Interpolate(inFile, outFile,startDate,endDate,intvl, maxgap = 5, stacked = Tr</div><div>ue, stackedCol = 2, tformat = &#39;%Y-%m-%d %H:%M:%S&#39;, debug = False).start()</div><div>&nbsp;&nbsp; return 0</div></div></div><div>
<br></div><div>That&#39;s the only difference I found on how the script is called from python and DLR.</div><div><br></div><div>Any comments?</div><div><br></div><div>regards,</div><div><br></div><div>wilfredo</div><br><div class="gmail_quote">
On Wed, Nov 12, 2008 at 2:56 PM, Dino Viehland <span dir="ltr">&lt;<a href="mailto:dinov@microsoft.com">dinov@microsoft.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">









<div lang="EN-US" link="blue" vlink="purple">

<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></p>

<p><span style="font-size:11.0pt;color:#1F497D">&nbsp;</span></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<div><div></div><div class="Wj3C7c"><br>
<b>Subject:</b> Re: [IronPython] Performance Issue</div></div></span></p>

</div><div><div></div><div class="Wj3C7c">

<p>&nbsp;</p>

<p>Thanks.</p>

<div>

<p>&nbsp;</p>

</div>

<div>

<p>But then If I don&#39;t use my defined scope, how I could fill
my function delegate?</p>

</div>

<div>

<p>&nbsp;</p>

</div>

<div>

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

</div>

<div>

<p>&nbsp;</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;);</p>

</div>

<div>

<p>&nbsp;</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?</p>

</div>

<div>

<p>&nbsp;</p>

</div>

<div>

<p>regards,</p>

</div>

<div>

<p>&nbsp;</p>

</div>

<div>

<p style="margin-bottom:12.0pt">wilfredo</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:</p>

<div>

<div>

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

<div>

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

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

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

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

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

</div>

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

<p><span style="font-size:11.0pt;color:#1F497D">&nbsp;</span></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></p>

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

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

<p><span style="font-size:11.0pt;color:#1F497D">&nbsp;</span></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></p>

</div>

<div>

<div>

<p>&nbsp;</p>

<p>&nbsp;</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;</p>

</div>

<div>

<div>

<p>&nbsp;</p>

</div>

<div>

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

</div>

<div>

<p>17:36</p>

</div>

<div>

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

</div>

<div>

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

</div>

<div>

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

</div>

<div>

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

</div>

<div>

<p>17:41</p>

</div>

<div>

<p>&nbsp;</p>

</div>

<div>

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

</div>

<div>

<p>&nbsp;</p>

</div>

<div>

<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.</p>

</div>

<div><pre>Thanks,</pre><pre>&nbsp;</pre><pre>Dave</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</pre>
<pre>Sent: Wednesday, November 12, 2008 8:32 AM</pre><pre>To: <a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">users at lists.ironpython.com</a></pre><pre>Subject: [IronPython] Performance Issue</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></p>

</div>

<p>&nbsp;</p>

</div>

</div></div></div>

</div>


<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><br>
<br></blockquote></div><br></div>