GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-126317: Simplify stdlib code by using itertools.batched() by dongwooklee96 · Pull Request #126323 · python/cpython Conversation
|
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@dongwooklee96 is the first-time contributor to the PyCon KR sprint today. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
11eb1ee to
4fa459b
Compare
|
dongwooklee96, could you avoid force pushing? https://devguide.python.org/getting-started/pull-request-lifecycle:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| tmp = list(islice(it, self._BATCHSIZE)) | ||
| n = len(tmp) | ||
| if n > 1: | ||
| for batch in batched(items, self._BATCHSIZE): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Is it worth using tmp instead of batch? It reduces the diff, but feel free to disregard.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to have a named variable that says what it is. "tmp" is too generic IMO.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I also think chunk would be better, should we change it to chunk?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Since we use "batchsize" I think it's fine to keep "batch"
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if len(batch) != 1: | ||
| write(MARK) | ||
| for i, x in enumerate(tmp, start): | ||
| for i, x in enumerate(batch, start): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Is it faster to calculate start + i in case of an error?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It's probably faster because we don't need to materialize an enumerate object but I'd benchmark that one to be sure.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sure, I understand. I won’t force-push from now on. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM. 👍
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.