Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-41324 Add a minimal decimal capsule API #21519

Merged
merged 21 commits into from
Aug 10, 2020

Conversation

skrah
Copy link
Contributor

@skrah skrah commented Jul 17, 2020

@skrah skrah requested a review from rhettinger as a code owner July 17, 2020 10:56
@skrah skrah changed the title Add a minimal decimal capsule API bpo-41324 Add a minimal decimal capsule API Jul 17, 2020
@pitrou
Copy link
Member

pitrou commented Jul 17, 2020

Also cc @xhochy just in case he's interested in this.

@pitrou
Copy link
Member

pitrou commented Jul 17, 2020

Thank you @skrah for this. AFAICT, the API here would be enough for explicitly-typed conversion.

For type inference (I'm not sure that would make sense, but perhaps) there would ideally be an additional API to get the number of digits in a Decimal (that is, len(dec.as_tuple().digits)).

Include/decimal.h Outdated Show resolved Hide resolved
@skrah
Copy link
Contributor Author

skrah commented Jul 17, 2020

For type inference (I'm not sure that would make sense, but perhaps) there would ideally be an additional API to get the number of digits in a Decimal (that is, len(dec.as_tuple().digits)).

That's a good point. Initially I thought people would use PyDec_Get(v)->digits, but then you need to include
mpdecimal.h. So actually we have two APIs: One for the people who use libmpdec directly and the easier
one. It would make sense to add PyDec_GetDigits(v).

Doc/c-api/decimal.rst Outdated Show resolved Hide resolved
@skrah skrah removed the skip news label Aug 10, 2020
@skrah skrah merged commit 39042e0 into python:master Aug 10, 2020
@bedevere-bot
Copy link

@skrah: Please replace # with GH- in the commit message next time. Thanks!

@skrah skrah deleted the minimal_decimal_api branch August 10, 2020 14:35
shihai1991 pushed a commit to shihai1991/cpython that referenced this pull request Aug 20, 2020
xzy3 pushed a commit to xzy3/cpython that referenced this pull request Oct 18, 2020
skrah added a commit to skrah/cpython that referenced this pull request Mar 5, 2021
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.

4 participants