Decode Python list into IList in function calls#10865
Decode Python list into IList in function calls#10865mmisol merged 9 commits intoDynamoDS:masterfrom
Conversation
Adds tests for the following conversion scenarios: - Python list => .NET IList (CPython fails) - .NET array => Python list - Python tuple => .NET array - Python tuple => .NET IList (CPython fails) - Python range => .NET array - Python range => .NET IList (CPython fails) - Python dict => .NET IDictionary (CPython fails) - .NET IDictionary => Python dict (CPython unkonwn) Also commented out some tests that fail in both engines but may be considered to fix in CPython: - .NET IList => Python list - Python array => .NET IList - Python dict => DS Dictionary Other types considered but not added as tests: - classes (can't convert them) - dictionary view objects (uncommon) - bytes, bytearray, memoryview (uncommon) - set, frozenset (uncommon) - complex (uncommon)
| return false; | ||
| } | ||
|
|
||
| using (var pyList = PyList.AsList(pyObj)) |
There was a problem hiding this comment.
I'm confused by this using statement, does AsList return a .net list or a Python List?
| { | ||
| // This is a no-op to prevent Python.NET from encoding generic lists | ||
| // https://github.com/pythonnet/pythonnet/pull/963#issuecomment-642938541 | ||
| return PyObject.FromManagedObject(value); |
There was a problem hiding this comment.
does this break examples where I want to call a python function with a list of ints?
def sum(data):
for i in data:
where data is a .net List<int> ?
There was a problem hiding this comment.
Good question. Let me try it and come back with the answer.
There was a problem hiding this comment.
sure, nothing wrong with more tests?
There was a problem hiding this comment.
okay, so l2 is a .net list because Flatten is a zt function?
There was a problem hiding this comment.
Yes, it's List.Flatten from our core nodes
mjkkirschner
left a comment
There was a problem hiding this comment.
This looks good @mmisol - I would like to get the tests passing soon though - need to check with @alfredo-pozo on that.

Purpose
Implements a decoder for Python sequence to transform them into generic
or non-generic IList. This relies on Python.NET 'PySequence.ToList'.
Also implements an encoder to perform a 'no-op'. This allows to treat
returned lists from function calls like .NET lists, which is the
behavior of Iron Python.
Declarations
Check these if you believe they are true
*.resxfilesReviewers
@DynamoDS/dynamo