<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:p="urn:schemas-microsoft-com:office:powerpoint" xmlns:a="urn:schemas-microsoft-com:office:access" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns:b="urn:schemas-microsoft-com:office:publisher" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:oa="urn:schemas-microsoft-com:office:activation" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:q="http://schemas.xmlsoap.org/soap/envelope/" xmlns:D="DAV:" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ois="http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:dir="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:udc="http://schemas.microsoft.com/data/udc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sub="http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/" xmlns:ec="http://www.w3.org/2001/04/xmlenc#" xmlns:sp="http://schemas.microsoft.com/sharepoint/" xmlns:sps="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:udcxf="http://schemas.microsoft.com/data/udc/xmlfile" xmlns:wf="http://schemas.microsoft.com/sharepoint/soap/workflow/" xmlns:mver="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns:mrels="http://schemas.openxmlformats.org/package/2006/relationships" xmlns:ex12t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ex12m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:Z="urn:schemas-microsoft-com:" 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;}
 /* 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;}
span.EmailStyle17
        {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'>Yep, the additional code is all there to deal with the dynamic
typing.&nbsp; There&#8217;s another significant difference though and that&#8217;s when you
declare classes.&nbsp; C# will generate a class exactly like how you specifiy it but
IronPython will generate a subclass of whatever your base type is, it will
override all of the virtual methods on it, and then turn any of those
invocations into a lookup in a dictionary and an invoke of the resulting
member.&nbsp; The actual generated class won&#8217;t contain any of the members you define
and it also won&#8217;t have a parameterless constructor.&nbsp; That breaks certain
scenarios where tools expect to find the real class or expect to be able to
create instances of some class.&nbsp; Ipy studio contains some code to be closer to
C# but it&#8217;s one big hack.<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>Matthew Barnard<br>
<b>Sent:</b> Wednesday, May 14, 2008 11:48 AM<br>
<b>To:</b> Discussion of IronPython<br>
<b>Subject:</b> Re: [IronPython] 2 Basic question about IronPython and dyn.
langs in general<o:p></o:p></span></p>

</div>

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

<p class=MsoNormal style='margin-bottom:12.0pt'>First, I would like to ask
anyone with more experience than myself (which is not much) to comment on the
validity of this test.<br>
I'm sure there are multitudes of differences I am not aware of that would make
these results misleading.<br>
<br>
2) IronPython Studio does indeed compile ipy code to MSIL, though I'm not clear
on how.<br>
The executable generated by IPy Studio contains MUCH more code than the C# exe.<br>
<br>
Comparing a for loop between IPy and C# leads me to the following:<br>
Because python's for loops are actually foreach loops (for i in list), I am
using a foreach loop in C# as well.<br>
Also, because C# has no native type akin to a python list (list resembles a
List&lt;&gt; more than anything),<br>
I am using List&lt;int&gt; for both, and iterating through it. I have
initialized each List&lt;&gt; outside of the test() method<br>
and added [0,1] to both.<br>
<br>
<span style='color:#3333FF'>static void test()<br>
{<br>
&nbsp;&nbsp;&nbsp; foreach (int i in lst)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; }<br>
}<br>
</span><span style='color:#009900'><br>
def test():<br>
&nbsp;&nbsp;&nbsp; for i in lst:<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pass</span><span style='color:#3333FF'><br>
</span><br>
The MSIL for the C# can be seen at <a
href="http://www.nomorepasting.com/getpaste.php?pasteid=15742&amp;seen=true&amp;numbered=on">http://www.nomorepasting.com/getpaste.php?pasteid=15742&amp;seen=true&amp;numbered=on</a><br>
and the MSIL for the IPy can be seen at <a
href="http://www.nomorepasting.com/getpaste.php?pasteid=15741&amp;seen=true&amp;numbered=on">http://www.nomorepasting.com/getpaste.php?pasteid=15741&amp;seen=true&amp;numbered=on</a><br>
both showing instructions only and with proper wrapping.<br>
<br>
Counting instructions only, the IPy generated 14 instructions more than the C#
in order to achieve what, in a practical situation (as in, how you would
actually use each), is the same code.<br>
<br>
Looking at the bigger picture, however, the difference in generated bytecode
between the C# application and the IPy application is VAST. Again, in a
practical sense, both are written in the same manner. That is, if you were to
write two applications to accomplish the same task, this is typically how it
would be accomplished. It is clear to see that the standard bare-bones C#
application produces far less bytecode than the standard bare-bones IPy
application.<br>
<br>
Please, correct me if I'm wrong. This is the extent of my knowledge.<br>
<br>
<br>
<br>
<o:p></o:p></p>

<div>

<p class=MsoNormal>On Wed, May 14, 2008 at 8:56 AM, Ben Hall &lt;<a
href="mailto:ben2004uk@googlemail.com">ben2004uk@googlemail.com</a>&gt; wrote:<o:p></o:p></p>

<p class=MsoNormal>I'll try to do my best to answer this.<br>
<br>
1) Because a large is dynamically typed, doesn't mean you can't do any<br>
verification on the code. Michael Foord told me about PyFlakes<br>
(<a href="http://divmod.org/projects/pyflakes" target="_blank">http://divmod.org/projects/pyflakes</a>)
and PyLint<br>
(<a href="http://pypi.python.org/pypi/pylint" target="_blank">http://pypi.python.org/pypi/pylint</a>)
which can do static analysis on<br>
the code to identity protential problems.<br>
<br>
2) If by native code you mean something like C++, then I expect so.<br>
Most languages are slower than C++, &nbsp;and it comes down to CPU cycles<br>
vs Developer Cycles. I'm sure developers are much more productive in<br>
Python than C++. &nbsp;Guess it depends on your application, but Python is<br>
running on lots of high performance systems so I don't really think<br>
its a problem.<br>
<br>
3) Not sure if I understand your question. You can compile Python into<br>
bytecode. &nbsp;Compiled Python code are .pyc,<br>
<br>
<a href="http://www.network-theory.co.uk/docs/pytut/CompiledPythonfiles.html"
target="_blank">http://www.network-theory.co.uk/docs/pytut/CompiledPythonfiles.html</a><br>
<br>
In 1.0, there was a sample of how to do this:<br>
<a
href="http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=IronPython&amp;ReleaseId=423"
target="_blank">http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=IronPython&amp;ReleaseId=423</a><br>
<br>
However, at the moment this is not supported in 2.0<br>
(<a
href="http://lists.whatwg.org/pipermail/users-ironpython.com/2008-February/006507.html"
target="_blank">http://lists.whatwg.org/pipermail/users-ironpython.com/2008-February/006507.html</a>)<br>
<span style='color:#888888'><br>
Ben</span><o:p></o:p></p>

<div>

<div>

<p class=MsoNormal><br>
<br>
<br>
On Wed, May 14, 2008 at 4:13 PM, Ben Aurel &lt;<a
href="mailto:ben.aurel@gmail.com">ben.aurel@gmail.com</a>&gt; wrote:<br>
&gt; hi<br>
&gt; I have two questions on two different subject but anyhow connected. Also I<br>
&gt; have to admit that I could probably find the answers myself. But I'm quite<br>
&gt; new to all that things and I have a lot to catch up to...<br>
&gt;<br>
&gt; If I understand correctly the are 2 main advantages when it comes to
dynamic<br>
&gt; languages:<br>
&gt; + Objects doesn't have to be typed be the developer<br>
&gt; &nbsp; (saves time, makes code shorter and better readable code)<br>
&gt; + Code is interpreted<br>
&gt; &nbsp; (no compilation step during development, source dont have to be
compiled<br>
&gt; for the target machines before deployment)<br>
&gt;<br>
&gt; which implies the 2 following disadvantages<br>
&gt; - Writing a lot of tests to catch potential runtime errors (no compile
time)<br>
&gt; - Slower than native code<br>
&gt;<br>
&gt; Questions:<br>
&gt;<br>
&gt; 1. Why belong the terms &quot;untyped&quot; and &quot;interpreted&quot;
somehow together? Why<br>
&gt; can't the type inference that has to be done at runtime &nbsp;not be done
at<br>
&gt; compiletime. I think the runtime interpreter has to compile the python<br>
&gt; bytecode to native code somehow - no?<br>
&gt; Why isn't there a possibility to *compile* python/ruby/perl/... code to<br>
&gt; native code at the first place?<br>
&gt;<br>
&gt; 2. I've read about, that it is possible to compile Python Code to msil
with<br>
&gt; IronPython. Unfortunately I'm not yet at the point where this run on my<br>
&gt; machine (macosx). So I do have to ask you: Is such a dll/exe the same as I<br>
&gt; would compile it from c#? Does similar language constructs (eg. for loop,<br>
&gt; class object creation) the same performance?<br>
&gt;<br>
&gt; Thanks in advance.<br>
&gt; Ben<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; One of the list members - Ben Hall - pointed me at one of his blog posts<br>
&gt; [1].<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; <a
href="http://blog.benhall.me.uk/2008/05/ironpython-classes-within-separate.html"
target="_blank">http://blog.benhall.me.uk/2008/05/ironpython-classes-within-separate.html</a><br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Users mailing list<br>
&gt; <a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>
&gt; <a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com"
target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
&gt;<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>

</div>

</div>

<p class=MsoNormal><br>
<br clear=all>
<br>
-- <br>
___________________________<br>
Matthew Barnard <o:p></o:p></p>

</div>

</body>

</html>