<div>Interesting; I would never have imagined that DataRow doesn&#39;t implement any interfaces.</div>
<div>&nbsp;</div>
<div>ItemArray doesn&#39;t look very expensive at all -- just a single allocation for the array, then the references are all copied over into it from an underlying ArrayList.</div>
<div><br>&nbsp;</div>
<div class="gmail_quote">On Mon, Jun 23, 2008 at 9:13 AM, Dino Viehland &lt;<a href="mailto:dinov@exchange.microsoft.com">dinov@exchange.microsoft.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div lang="EN-US" vlink="purple" link="blue">
<div>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">Actually it's not related to the interfaces – DataRow implements no interfaces!&nbsp; Instead what it has is a default member which we of course map into __getitem__.&nbsp; And Python says that all things with __getitem__ can be enumerated by going from 0 until you get an exception.</span></p>

<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">&nbsp;</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">In 2.0 we apparently support this conversion on user defined types but not on built-in .NET types.&nbsp; I'm actually doing some work now which will unify the .NET vs User-Defined type code paths so this will go away but I've opened bug #17142 to track this (<a href="http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=17142" target="_blank">http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=17142</a>).&nbsp; That way afterwards we'll make sure we've got a test in place and it won't regress in the future.</span></p>

<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">&nbsp;</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">Now that being said you probably don't actually want to be doing this for performance reasons </span><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: Wingdings">J</span><span style="FONT-SIZE: 11pt; COLOR: #1f497d">.&nbsp; The way we know this iteration is complete is when an exception is thrown which is going to be bad for perf.&nbsp; Calling row.ItemArray is going to give you a real enumerable object which terminates w/o an exception so you may see better perf that way - of course that seems to make a copy of all the rows, so there's a trade-off to be made here…</span></p>

<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">&nbsp;</span></p>
<div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; BORDER-LEFT: medium none; PADDING-TOP: 3pt; BORDER-BOTTOM: medium none">
<p><b><span style="FONT-SIZE: 10pt">From:</span></b><span style="FONT-SIZE: 10pt"> <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>Curt Hagenlocher<br>
<b>Sent:</b> Monday, June 23, 2008 8:37 AM<br><b>To:</b> Discussion of IronPython<br><b>Subject:</b> Re: [IronPython] DataRows and IronPython 2.0 B3</span></p></div>
<div>
<div></div>
<div class="Wj3C7c">
<p>&nbsp;</p>
<div>
<p>It&#39;s very unlikely that this was intentional.&nbsp; I suspect that it&#39;s related to a change in the way we handle interfaces -- this wouldn&#39;t be the first unanticipated consequence of that change. :/</p></div>
<div>
<p><br>&nbsp;</p></div>
<div>
<p>On Mon, Jun 23, 2008 at 8:30 AM, Michael Foord &lt;<a href="mailto:fuzzyman@voidspace.org.uk" target="_blank">fuzzyman@voidspace.org.uk</a>&gt; wrote:</p>
<p>Note that we can fix it by iterating over &#39;row.ItemArray&#39; instead, I just wondered if the breakage was intentional.<br><span style="COLOR: #888888"><br>Michael Foord</span> </p>
<div>
<div>
<p><br><br>Michael Foord wrote:</p>
<p>Hello all,<br><br>I&#39;m further investigating potential compatibility issues with moving Resolver One to IronPython 2, and I&#39;ve encountered a change in behaviour with respect to iterating over DataRows.<br><br>The script below works in IronPython 1, printing all the data in the rows. In IronPython 2.0 B3 it raises an exception.<br>
<br>IronPython 1:<br>C:\compile&gt;c:\Binaries\ironpython\ipy.exe test_data.py<br>0 System.Data.DataRow<br>&nbsp; &nbsp;0 A Big Boy Did It and Ran Away<br>1 System.Data.DataRow<br>&nbsp; &nbsp;0 Affective Computing<br>2 System.Data.DataRow<br>
&nbsp; &nbsp;0 Clear and Present Danger<br><br>IronPython 2:<br>C:\compile&gt;c:\Binaries\ironpython2\ipy.exe test_data.py<br>0 &lt;System.Data.DataRow object at 0x000000000000002B [System.Data.DataRow]&gt;<br>Traceback (most recent call last):<br>
&nbsp;File &quot;test_data.py&quot;, line 29, in test_data.py<br>TypeError: expected IEnumerator, got DataRow<br><br><br>Test script:<br><br>import clr<br>clr.AddReference(&#39;System.Data&#39;)<br><br>from System.Data import DataSet<br>
from System.Data.Odbc import OdbcConnection, OdbcDataAdapter<br><br><br>connectString = (<br>&nbsp; &quot;DRIVER={MySQL ODBC 3.51 Driver};&quot;<br>&nbsp;&quot;blah blah blah&quot;<br>&nbsp; &quot;OPTION=3;&quot;<br>)<br><br>query = &quot;SELECT title FROM books WHERE price &gt; 2 ORDER BY title&quot;<br>
<br>connection = OdbcConnection(connectString)<br>adaptor = OdbcDataAdapter(query, connection)<br>dataSet = DataSet()<br>connection.Open()<br>adaptor.Fill(dataSet)<br>connection.Close()<br><br>for rowIndex, row in enumerate(dataSet.Tables[0].Rows):<br>
&nbsp; print rowIndex, row<br>&nbsp; for colIndex, data in enumerate(row):<br>&nbsp; &nbsp; &nbsp; print &#39; &nbsp; &nbsp;&#39;, colIndex, data<br><br>Michael Foord<br><a href="http://www.ironpythoninaction.com/" target="_blank">http://www.ironpythoninaction.com/</a><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>

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