◐ Shell
reader mode source ↗
Skip to content

bpo-33073: Adding as_integer_ratio to ints.#8750

Merged
rhettinger merged 18 commits into
python:masterfrom
lisroach:iss_33073
Sep 14, 2018
Merged

bpo-33073: Adding as_integer_ratio to ints.#8750
rhettinger merged 18 commits into
python:masterfrom
lisroach:iss_33073

Conversation

@lisroach

@lisroach lisroach commented Aug 12, 2018

Copy link
Copy Markdown
Contributor

Adding as_integer_ratio to ints to make them more interoperable with floats.

https://bugs.python.org/issue33073

@mdickinson

Copy link
Copy Markdown
Member

@lisroach Thanks for the update. I've pushed a commit that should fix the failing test_doctest.

@mdickinson mdickinson 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.

Hide comment

@lisroach If you're okay with my recent updates, I think this PR is ready to merge.

@mdickinson mdickinson added the type-feature A feature request or enhancement label Aug 25, 2018

@mdickinson mdickinson 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.

Hide comment

Changing my approval due to the issues Serhiy noted. @lisroach do you want to tackle the outstanding comments? I'm happy to pick this up if not.

@bedevere-bot

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.

@lisroach

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again.

I am not sure if I could do the boolean check better- somehow in one line? I'm open to advice!

Thanks for all the reviews @mdickinson and @serhiy-storchaka it's been really helpful!

26 hidden items Load more…
@lisroach

Copy link
Copy Markdown
Contributor Author

@eric-wieser I believe Serhiy's thinking is correct, it should be (1, 1).
Subclasses of int inherit the same operations of int, and those operations create instances of int (as opposed to creating an instance of the subclass). For example, if we look at the unary plus of int:

>>> class Int(int):
...     pass
...
>>> x = Int(42)
>>> type(+x)
<class 'int'>
>>> type(+True)
<class 'int'>

@bedevere-bot

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.

@rhettinger rhettinger dismissed mdickinson’s stale review September 14, 2018 05:34

Am checking to see the Serhiy's issues are resolved.

@eric-wieser

Copy link
Copy Markdown
Contributor

Reviving a comment hidden away above - should operator.index / PyNumber_Index / int->tp_as_number->nb_index call _PyLong_Copy too for consistency?

@rhettinger rhettinger merged commit 5ac7043 into python:master Sep 14, 2018
@eric-wieser

eric-wieser commented Sep 14, 2018

Copy link
Copy Markdown
Contributor

ISTM, the code is reasonable as-is.

Despite the missing null check and invalid C syntax that works only because of a macro?

@rhettinger

Copy link
Copy Markdown
Contributor

Eric, I didn't see your comments prior to merging. See PR 9297 for the cleanup. The part that was fine as-is was using PyTuple_Pack() on two different code paths.

@eric-wieser

eric-wieser commented Sep 14, 2018

Copy link
Copy Markdown
Contributor

Agreed, the two code paths thing was unimportant. #9297 seems to address all my comments, other than the question about nb_index, which is tangential anyway

@rhettinger

Copy link
Copy Markdown
Contributor

Can you note your review on 9297 please.

@eric-wieser

Copy link
Copy Markdown
Contributor

If that's aimed at me, I don't know what you're asking me to do.

@serhiy-storchaka serhiy-storchaka 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.

Hide comment

This PR was merged too soon. There are several issues with it. See also comments by @sir-sigurd and @eric-wieser.

@serhiy-storchaka

Copy link
Copy Markdown
Member

Reviving a comment hidden away above - should operator.index / PyNumber_Index / int->tp_as_number->nb_index call _PyLong_Copy too for consistency?

This is a different issue. And I think that it should not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.