FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-24416: Return a IsoCalendarDate from date.isocalendar() by corona10 · Pull Request #15633 · python/cpython · GitHub

Repository navigation

bpo-24416: Return a IsoCalendarDate from date.isocalendar() - #15633

Closed
corona10 wants to merge 20 commits into
python:masterfrom
corona10:bpo-24416
Closed

corona10 wants to merge 20 commits into
python:masterfrom
corona10:bpo-24416

Conversation

corona10 commented Sep 1, 2019 •
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Contributor

/cc @abalkin @pganssle

taleinat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

In addition to the in-line comments, note also that the new IsoCalendarDate class needs its own (small) section in the docs.

Comment thread Doc/library/datetime.rst Outdated
Comment thread Doc/whatsnew/3.9.rst Outdated
Comment thread Lib/datetime.py Outdated
Comment thread Lib/datetime.py Outdated
Comment thread Lib/test/datetimetester.py Outdated
Comment thread Doc/whatsnew/3.9.rst Outdated

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Comment thread Modules/_datetimemodule.c Outdated
Comment thread Modules/_datetimemodule.c Outdated
Comment thread Modules/_datetimemodule.c Outdated
corona10 changed the title bpo-24416: Return a namedtuple from date.isocalendar() [WIP] bpo-24416: Return a namedtuple from date.isocalendar() Sep 1, 2019

corona10 commented Sep 1, 2019

Copy link
Copy Markdown
Member Author

@taleinat @ZackerySpytz cc @pganssle @abalkin

First of all, thanks for the code review.
I 've reflected the review for this PR.

However, other comments have been raised by the core developer on whether this patch is acceptable.
IMHO, It is a good idea to review the patch after the discussion is complete.

Again, thank you for the code reviews. :)

corona10 changed the title [WIP] bpo-24416: Return a namedtuple from date.isocalendar() bpo-24416: Return a namedtuple from date.isocalendar() Sep 1, 2019
Comment thread Doc/library/datetime.rst Outdated
brandtbucher added the type-feature A feature request or enhancement label Sep 1, 2019

corona10 commented Sep 2, 2019

Copy link
Copy Markdown
Member Author

@rhettinger
Is there anything can review with this PR except updating PR naming and updating documentation?

pganssle left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I haven't had time to do a full review yet, but I've added one comment about refactoring a test (feel free to dispute that if you disagree), and I do think that we should make the particular class used a private implementation detail and not expose it, per my comment here.

@taleinat I know that you asked for IsoCalendarDate to be documented - are you OK with us only guaranteeing that the return value has year, week and day fields but not exposing the actual class for isinstance or construction purposes? If so, I think we can just document those properties in the isocalendar() documentation.

Comment thread Lib/test/datetimetester.py Outdated

Copy link
Copy Markdown
Contributor

Marking this as closed. See the discussion on BPO where we've decided that collections.namedtuple() wasn't the way to go here. Instead, C functions should use structseq.

Thanks for PR and sorry the effort didn't come to fruition.

rhettinger closed this Sep 8, 2019

pganssle commented Sep 8, 2019 •
edited
Loading

Copy link
Copy Markdown
Member

@rhettinger This PR uses a structseq, it's what we used for the benchmarks, and I see no reason to close it. Dong-Hee can just push more commits with any changes you might request.

I'm going to re-open this, since @taleinat and I already have review comments on it and it's unclear what you would want @corona10 to do differently here (and even so, comments and pushing new commits would probably be preferable to closing it and opening a new PR).

pganssle reopened this Sep 8, 2019
tim-one changed the title bpo-24416: Return a namedtuple from date.isocalendar() bpo-24416: Return a structseq from date.isocalendar() Sep 8, 2019

tim-one commented Sep 8, 2019

Copy link
Copy Markdown
Member

I changed the title to replace "named tuple" with "structseq". All the code and doc changes checked in here should do something similar - the correct name is "struct sequence" (see, e.g., the existing docs for sys.float_info).

Copy link
Copy Markdown
Contributor

Paul, are you still wanting to go down the path of using collections.namedtuple() instead of structseq? If not, this PR needs to be closed.

rhettinger self-assigned this Sep 8, 2019

tim-one commented Sep 8, 2019

Copy link
Copy Markdown
Member

Raymond, the actual current code here uses PyStructSequence_XXX calls. Not named tuples anymore. That's why I changed the title 😄.

Copy link
Copy Markdown
Contributor

I had make a quick scan of the latest version and didn't expect to see from collections import namedtuple on line 11 of Lib/datetime.py.

tim-one commented Sep 8, 2019

Copy link
Copy Markdown
Member

Yes, the Python and C implementations differ in the current state. I just assumed Paul was keen to change the C version to structseqs first, to get his benchmarks done.

Copy link
Copy Markdown
Contributor

Also, I had thought we were going to use "named tuple" (two words) to cover the generic concept including both collections.namedtuple() and structseq. See https://docs.python.org/3/glossary.html#term-named-tuple

I don't think the user ever sees something called a "structseq".

>>> import time
>>> time.localtime()
time.struct_time(tm_year=2019, tm_mon=9, tm_mday=8, tm_hour=16, tm_min=50, tm_sec=17, tm_wday=6, tm_yday=251, tm_isdst=1)
>>> type(_)
<class 'time.struct_time'>

I don't think the API of a structseq is publicly documented anywhere, so it may not make sense to refer to it at all. For example, see what was done for https://docs.python.org/3/library/time.html#time.struct_time

Copy link
Copy Markdown
Member Author

I have made the requested changes; please review again

Copy link
Copy Markdown

Thanks for making the requested changes!

@pganssle, @taleinat: please review the changes made to this pull request.

Copy link
Copy Markdown
Member Author

cc @vstinner

Comment thread Lib/datetime.py


class IsoCalendarDate(tuple):

pppery Jan 16, 2020 •
edited
Loading

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
__slots__ = ()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@pppery Can you explain the reason about this suggestion?

pganssle commented May 8, 2020 •
edited
Loading

Copy link
Copy Markdown
Member

@corona10 Hey, sorry I never got back to this, I've been swamped with PEP 615, but I'd love to get this in before the feature freeze.

Do you mind letting me know the current state of things? Do you have a recommendation between this implementation and the other one?

I'm also increasingly amenable to the idea of just having this thing named _IsoCalendar or something (particularly if we can overload the __repr__ to have it return IsoCalendar(...) instead?) if it's too complicated to do anything else.

corona10 commented May 9, 2020

Copy link
Copy Markdown
Member Author

@pganssle

Hmm, I should remember what I tried before for this issue :)

AFAIK(??) I still prefer the current PR implementation.
Since #17651 is too verbose. (It's just my opinion)
he current implementation is able to compatible with pure python code.
This PR can be the same level of verbose but we can bring compatible issues easily.
(You know namedtuple and structseq is quite different.)

But if you decide specific requirements then we can change the implementation.
And I prefer the start with new PR.
We(or You) can create a new PR to start.

corona10 commented May 9, 2020

Copy link
Copy Markdown
Member Author

or we have to think that this issue is should be solved?

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting change review type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.


Back | FazBrowse Home | New Git URL