GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-132908: check the return type of isnormal() and issubnormal() by picnixz · Pull Request #136039 · python/cpython

Conversation

@picnixz

@picnixz picnixz commented Jun 27, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

I've actually stumbled upon the isnormal() C11 requirements (which I assume are the same as issubnormal() ones but I don't have a C23 copy) and I think we can add those checks (I first thought about returning the integer value given by signbit but in C++, it returns a bool instead of just an integer [on some implementations it gives the power of 2 representing the sign bit].

  • Issue: Have math.isnormal() and, perhaps, math.issubnormal()? #132908

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@picnixz
check the return type of isnormal() and issubnormal()
5a729f0
@picnixz
picnixz requested a review from skirpichev June 27, 2025 13:50
@picnixz picnixz added the skip news label Jun 27, 2025
@bedevere-app bedevere-app Bot added awaiting core review tests Tests in the Lib/test dir labels Jun 27, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Jun 27, 2025
Have math.isnormal() and, perhaps, math.issubnormal()? #132908
Closed
skirpichev
skirpichev approved these changes Jun 27, 2025
View reviewed changes

@skirpichev skirpichev left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Looks good, but we don't have similar checks for other predicates, e.g. isfinite(). That's why I don't sure we should add such checks.

But it's up to you. BTW, probably you can remove comments - we have documentation, right?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@picnixz

picnixz commented Jun 27, 2025

Copy link
Copy Markdown
Member Author

That's why I don't sure we should add such checks.

Oh! Ok makes sense. Let's not burden the already existing tests. I've added it in signbit because signbit may return the corresponding power-of-two if there is a sign bit. But I think it's the only one that is not named "isXXX()" and that returns a boolean.

But it's up to you. BTW, probably you can remove comments - we have documentation, right?

Right. I actually wanted to add a comment in the tests in case we change the return value for some reason (it could serve as a regression test as well). I don't want to burden the online docs with those implementation details (in C++ for instance, it's a boolean that is returned, so depending on the page of cppreference you land, you may be like "why are they explaining this?").


Sorry for the noise! I'll keep the check in the signbit PR because of the lack of the is prefix but won't merge this one.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz picnixz closed this Jun 27, 2025
@picnixz

picnixz commented Jun 27, 2025

Copy link
Copy Markdown
Member Author

@skirpichev Btw, do you remember if we have an issue about positional-only arguments in math.* ? all functions are positional-only but I don't remember what we decided.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz
picnixz deleted the refactor/test/issnormal-132908 branch June 27, 2025 14:43
@skirpichev

skirpichev commented Jun 27, 2025

Copy link
Copy Markdown
Member

do you remember if we have an issue about positional-only arguments in math.* ? all functions are positional-only but I don't remember what we decided.

@picnixz, I'm not sure we have an issue about this. Perhaps, you are about this pr: #131886 ?

In similar way we could change signatures in the math module. The cost is a small regression in processing arguments. (Perhaps, it could be solved.)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

@skirpichev skirpichev skirpichev approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting core review skip news tests Tests in the Lib/test dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@picnixz @skirpichev
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.