Skip to content

Adds support to convert iterators to arrays - #928

Merged
filmor merged 1 commit into
pythonnet:masterfrom
jmlidbetter:iters_to_arrays
Aug 5, 2019
Merged

filmor merged 1 commit into
pythonnet:masterfrom
jmlidbetter:iters_to_arrays

Conversation

@jmlidbetter

@jmlidbetter jmlidbetter commented Aug 1, 2019 •

Copy link
Copy Markdown
Contributor

What does this implement/fix? Explain your changes.

Python 3 has much more liberal use of iterators, e.g. getting keys or values from a dictionary. This adds functionality to convert python object which support the iterator protocol to arrays in C#.

Does this close any currently open issues?

No

Any other comments?

N/A

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • If an enhancement PR, please create docs and at best an example
  • Add yourself to AUTHORS
  • Updated the CHANGELOG

@jmlidbetter
jmlidbetter force-pushed the iters_to_arrays branch 2 times, most recently from 0bd4a10 to 2e51321 Compare August 2, 2019 07:47
@filmor

filmor commented Aug 2, 2019

Copy link
Copy Markdown
Member

This looks like a good addition feature-wise, but there is quite a bit of duplicated code in it. I think it would be better if we had /one/ implementation based on the iterator protocol, that just uses an additional size hint if len is implemented.

@jmlidbetter

Copy link
Copy Markdown
Contributor Author

This looks like a good addition feature-wise, but there is quite a bit of duplicated code in it. I think it would be better if we had /one/ implementation based on the iterator protocol, that just uses an additional size hint if len is implemented.

Sure. Presumably sequence protocol => iterator protocol?

@filmor

filmor commented Aug 2, 2019

Copy link
Copy Markdown
Member

It says so in the docs: https://docs.python.org/2/library/stdtypes.html#iterator-types as well as https://docs.python.org/3/library/stdtypes.html#iterator-types:

Sequences [...] always support the iteration methods.

@jmlidbetter

Copy link
Copy Markdown
Contributor Author

It says so in the docs: https://docs.python.org/2/library/stdtypes.html#iterator-types as well as https://docs.python.org/3/library/stdtypes.html#iterator-types:

Sequences [...] always support the iteration methods.

Ok, have redone - always uses iterator protocol now.

@Cronan

Cronan commented Aug 5, 2019

Copy link
Copy Markdown
Contributor

@filmor Passed!

@filmor

filmor commented Aug 5, 2019

Copy link
Copy Markdown
Member

This looks great, thanks :)

@filmor
filmor merged commit 51a1868 into pythonnet:master Aug 5, 2019
AlexCatarino pushed a commit to QuantConnect/pythonnet that referenced this pull request Jun 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants