[proxy] github.com← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light
/ cpython Public

Conversation

Copy link
Contributor

lisroach commented Sep 16, 2018

rhettinger requested a review from tim-one September 17, 2018 03:53
Copy link
Member

tim-one left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you - I'll even use it ;-)

Copy link
Member

serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

There are following technical problems with current changes:

  1. The default value for initial is documented and exposed in the signature as None, but passing None is not the same as omitting the initial argument.
  2. Pickling and copying the accumulate iterator loses the initial value.

Copy link

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

Copy link
Contributor

The pickling and copying should be a separate tracker item for Kristjan Jonnson to update his own code (I think he is the only user of that feature and would be willing to shoulder some of the recurring maintenance burden arising from that code).

Copy link
Member

I don't think that ignoring initial=None is right. And you did not think this too, according to your initial implementation.

Copy link
Contributor

It depends on whether you think None would be a useful input value to an accumulation.

The start=_sentinel approach gives more flexibility but is problematic for complicating the pure python version in the docs and for wrestling with argument clinic (I suspect we would have to remove the clinic code entirely and forgo the signature it generates). If so, I'm inclined to leave the PR as is.

Copy link
Member

This will make a subtle difference between accumulate() and reduce(), and also max(), iter(), next(), getattr(), etc which accept an optional argument, but distinguish None from no argument. I think this will be a bug magnet.

As for the pure python version in the docs, the pure python version of reduce() uses None as a sentinel.

Copy link
Contributor

Added pickle support (when initial is set, use chain([initial], it)). Please take a look.

Copy link
Member

serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

Please add an entry in What's New.

lz->initial, lz->it);
if (it == NULL)
return NULL;
return Py_BuildValue("O(OO)O", Py_TYPE(lz),
Copy link
Member

Choose a reason for hiding this comment

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

"O(NO)O"

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO this is to minor to warrant a WhatsNew entry. Whatsnew should be much more selective. The reason we have whatsnew is that NEWS is already unmanageably lengthy to read.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed.

if (it == NULL)
return NULL;
return Py_BuildValue("O(OO)O", Py_TYPE(lz),
it, lz->binop?lz->binop:Py_None, Py_None);
Copy link
Member

Choose a reason for hiding this comment

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

Please add spaces around ? and : for PEP 7.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's better without the spaces to show the grouping and for consistency with the surrounding code.

Copy link
Member

The pickling part LGTM. But I think that initial=None should not be ignored.

Copy link
Contributor

Serhiy, thank you for the suggestion about initial=None, but I'm going to decline. I want to keep the argument clinic here and I agree with Tim's post on the subject. As module maintainer, I get to make the final call on the API.

Let's clear the way for Lisa to apply her first patch own her own. Please clear the review request so this can move forward. It has already consumed far too much time in relative to the value of the feature.

Copy link
Member

This feature is just too complex for its value.

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.

6 participants