<div dir="ltr">Hi Markus,<div><br></div><div>Thank you for your excellent reply to my question. I was able to just use the constructor, for some reason I thought it wasn't working, when in reality it was working and I was just adding the incorrect items to the tuple. I appreciate your response!</div><div><br></div><div>Regards.</div><div><br></div><div>Slide</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Aug 24, 2015 at 1:27 AM Markus Schaber <<a href="mailto:m.schaber@codesys.com">m.schaber@codesys.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Von: Slide<br>
<br>
> Can anyone tell me why this method is internal?!<br>
<br>
My educated guess is that it uses the items array by value without copying it, while all public ways to construct the tuple actually copy the sequence you pass. Making that method public would allow users to create a tuple which may be modified by keeping a reference to the array. Making such an API public is rather risky.<br>
<br>
But you can have almost the same effect by using the public PythonTuple constructors directly.<br>
<br>
Only the EMPTY optimization will not work, which may or may not be what you want.<br>
<br>
PS: Note that IronPython standard library itself can still access said method, as the [InternalsVisibleTo]-Attribute on IronPython allows access to internal methods from the IronPython.Modules and IronPythonTest assemblies.<br>
<br>
PS 2: I'm not sure whether the MakeItems() method internally used works correctly when we pass strings which contain non-BMP characters. It seems to assume a character is a single 16-bit unit. We should investigate that, and compare it to Python 2 and 3 behavior with Unicode strings containing non-BMP characters. I'm not mandating for a quick change here, but especially when Python 3.x is targeted with IronPython, we should use the most sensible behavior and (possibly) document it as one of the differences in string handling. (Another one is indexing [] into strings which contain non-BMP characters.)<br>
<br>
PS 3: It might be an optimization to add a check o for being a ICollection, and directly allocate an array of the right size and using CopyTo. For large collections, this will be more efficient than the List<Object> constantly reallocating. On the other hand, the assumption may be that it's mostly used for small lists, and the additional type check / dynamic cast makes up for the difference. (However, we might replace bot the "is List" and "o as object[]" branches with the ICollection branch, as both implement ICollection, effectively saving one dynamic cast...)<br>
<br>
Best regards<br>
<br>
Markus Schaber<br>
<br>
CODESYS® a trademark of 3S-Smart Software Solutions GmbH<br>
<br>
Inspiring Automation Solutions<br>
________________________________________<br>
3S-Smart Software Solutions GmbH<br>
Dipl.-Inf. Markus Schaber | Product Development Core Technology<br>
Memminger Str. 151 | 87439 Kempten | Germany<br>
Tel. +49-831-54031-979 | Fax +49-831-54031-50<br>
<br>
E-Mail: <a href="mailto:m.schaber@codesys.com" target="_blank">m.schaber@codesys.com</a> | Web: <a href="http://codesys.com" rel="noreferrer" target="_blank">codesys.com</a> | CODESYS store: <a href="http://store.codesys.com" rel="noreferrer" target="_blank">store.codesys.com</a><br>
CODESYS forum: <a href="http://forum.codesys.com" rel="noreferrer" target="_blank">forum.codesys.com</a><br>
<br>
Managing Directors: Dipl.Inf. Dieter Hess, Dipl.Inf. Manfred Werner | Trade register: Kempten HRB 6186 | Tax ID No.: DE 167014915<br>
________________________________________<br>
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received<br>
this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure<br>
or distribution of the material in this e-mail is strictly forbidden.<br>
</blockquote></div>