Wish: IronPythonList to GH_Array default conversion

Hi @piac,

How feasible it is to have automatic transformation of IronPythonLists into GH_Arrays implemented, when they are output of an GhPython component?

Is there a possibility for an output type hinting?
That’s in case of a nested python list to GH_Tree conversion.

Thanks in advance.

PS: if the implementation of this is not that big, could it also be added to GH1?
Does GH1 support ArrayLists ?

GH1 tries to stay away from non-generic collections as much as possible, as should everyone else working on .NET 2.0 or later.

Hi David,

I don’t know what that means.

Update:
Ok, I got it (Generic-Non-Generic difference)

Well, this is why I mentioned about output hinting. There could be a number of hints transforming an IronPython non-generic list into a typed one (I assume an Array[sometype]). So the user can pick what kind of data to output.

e.g. IronPython list

myList = ["1",2,3,4,5.0]

and there are three hints

  • Array[String] transforming the list into [“1”,“2”,“3”,“4”,“5.0”]
  • Array[Int] → [1,2,3,4,5]
  • Array[Double] → [1.0,2.0,3.0,4.0,5.0]

in case of [ [ ],[ ],[ ] ] kind of list the above hinting should show an exception and a Tree transformation should be performed, a different hint.

Instead of slowing things down by making GhPython perform a bunch of guesses as what to generate, you could just output typed arrays.

import System
list = [1,2,3,4]
# convert list to an array of integers
a = System.Array[int](list)

This is the thing I am asking to happen by output hinting.
No guessing. If there is no hint and you export nested list you’ll see IronPythonList bla bla. But if you pick a hint to be exactly Array[int] it will automatically translate it to GH list, without having to implement the translation inside the scripting component.