Skip to content

Conversation

@MSeifert04
Copy link
Contributor

This is more or less just a test for bpo-26828.

I did some benchmarks and it seems the overhead for small iterables is significant (up to 20% slower for 10, 10 items long iterables) and the break-even seems to be at 50 (2 iterables) - 100 (10 iterables) items. However it takes 100k-1m elements in the benchmarks for the length_hint variant to be 20% faster.

However I'm not sure my micro-benchmarks are really accurate.

@mention-bot
Copy link

@MSeifert04, thanks for your PR! By analyzing the history of the files in this pull request, we identified @berkerpeksag, @ncoghlan and @serhiy-storchaka to be potential reviewers.

@brettcannon brettcannon added the type-feature A feature request or enhancement label Apr 17, 2017
@rhettinger rhettinger self-assigned this Apr 26, 2017
}

if (length_hint == -1)
return NULL;
Copy link
Member

@nascheme nascheme Apr 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks incorrect to me. Shouldn't it test if it_len == PY_SSIZE_T_MAX? If this is a bug, your unit tests are not extensive enough. Add tests that feed generators to zip and map and check to ensure that __length_hint__ returns the correct value (None?) when no length can be determined.

Copy link
Contributor Author

@MSeifert04 MSeifert04 Apr 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it_len == PY_SSIZE_T_MAX should be valid because if there's no iterator then the function short-circuits immediatly but if there are iterators then PY_SSIZE_T_MAX is a valid length.

However the issue was recently challenged and eventually closed as "no fix" so I haven't continued here.

@MSeifert04 MSeifert04 closed this Apr 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants