Skip to content

Adds support to convert iterators to arrays #928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2019

Conversation

jmlidbetter
Copy link
Contributor

@jmlidbetter jmlidbetter commented Aug 1, 2019

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
Copy link
Member

filmor commented Aug 2, 2019

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
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
Copy link
Member

filmor commented Aug 2, 2019

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
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
Copy link
Contributor

Cronan commented Aug 5, 2019

@filmor Passed!

@filmor
Copy link
Member

filmor commented Aug 5, 2019

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