-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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-29534: _decimal difference with _pydecimal #65
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA. This is necessary for legal reasons before we can look at your contribution. Please follow these steps to help rectify the issue:
Thanks again to your contribution and we look forward to looking at it! |
The new behaviour seems like the right thing to me. Can you rework the code to avoid the repetition of the |
@mdickinson thanks for the comment! I've just reworked my PR to avoid code duplication. |
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.
Changes mostly LGTM, modulo a couple of nitpicks.
Still needs:
- contributor agreement for Andrew
- Misc/NEWS entry
Lib/_pydecimal.py
Outdated
return cls(repr(f)) | ||
if _math.copysign(1.0, f) == 1.0: | ||
sign = 0 | ||
sign = 0 if f >=0 else 1 |
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.
Style nit: please add a space after the >=
.
Lib/test/test_decimal.py
Outdated
@@ -5467,6 +5477,7 @@ def __abs__(self): | |||
self.assertEqual(Decimal.from_float(cls(101.1)), | |||
Decimal.from_float(101.1)) | |||
|
|||
|
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.
This change seems unrelated to the PR; please could you revert it?
Lib/test/test_decimal.py
Outdated
@@ -1185,6 +1185,16 @@ def test_wide_char_separator_decimal_point(self): | |||
self.assertEqual(format(Decimal('100000000.123'), 'n'), | |||
'100\u066c000\u066c000\u066b123') | |||
|
|||
def test_decimal_from_float_repr(self): |
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.
This is just nitpicking, but I think we're testing the wrong thing here: the change is in the type of the object that's passed to the Decimal
subclass; the repr
of the value was just a convenient way of demonstrating the difference in behaviours between the Python and C decimal implementations. How about recording and checking the type instead of the repr?
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.
@mdickinson good idea, thanks!
@mdickinson thanks! I've fixed all the nitpickings you mentioned. Also updated NEWS. |
@andrewnester: Thank you! One last nitpick: please could you change the name of the test? Apart from that, this looks good to go. Did you fill out the CLA? |
@mdickinson fixed. yes, I filled it couple of hours ago :) |
In, that case, LGTM unconditionally. |
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.
LGTM
Codecov Report
@@ Coverage Diff @@
## master #65 +/- ##
==========================================
- Coverage 82.37% 82.37% -0.01%
==========================================
Files 1427 1427
Lines 350948 350959 +11
==========================================
+ Hits 289095 289100 +5
- Misses 61853 61859 +6 Continue to review full report at Codecov.
|
The coverage gods seem a bit peeved, but I can't make head or tail of the coverage report. Which 6 lines are new misses? (And which 5 lines are new hits?) |
Merged. Thanks for the contribution! |
* refactor: return BB metadata from BB creation function * feat: add execute jitted code in BB_BRANCH * nit: disable JIT debug * nit: Removed debugging comment in ceval_macros.h * nit: Removed indirection warning in jit.py --------- Co-authored-by: Jules <julia.poo.poo.poo@gmail.com>
Fix for https://bugs.python.org/issue29534