-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
_decimal
and _pydecimal
compatibility differences
#117056
Comments
It is other way: the Python implementation accepts and passes the The implementation is not designed for overloading these special methods in subclasses. Perhaps it would be better to implement the logic of addition in other method (e.g. cc @mdickinson |
Ah, right, I managed to get it backwards 😅 |
FWIW the extra context parameter was considered an implementation detail from the outset. It was not a documented part of the public API. In practice this was worked out well and proven harmless. The users likely never see it because arithmetic dunder methods aren't typically called directly (the I recommend leaving this as-is. There isn't anything worth churning all this long stable code. The referenced issue in the If anything, I would suggest adding a note to the docs acknowledging the implementation detail.
This would be a lot of code churn for almost no benefit. It would make the module even harder to read and maintain. Also, in the pure python verion, and extra layer of function call forwarding would just may the module slower. |
Bug report
Bug description:
There are two backends for the
decimal
module, one fromlibmpdec
(_decimal
) and the other being a native re-implementation in Python (_pydecimal
).The signatures of methods like
Decimal.__add__
take a namedcontext
argument when imported from_pydecimal
, but cannot accept that argument when imported from_decimal
.mpdecimal
is not bundled with Python installations on all platforms, and my understanding is that there are even more changes to how it's packaged incoming as per #115119. The difference between the two backends has caused cross-platform incompatibility for at least one project, and I'd argue it's very difficult for anyone who encounters this problem to understand the issue because the error messages mention nothing about an external dependency being required.Would it be possible to remove the
context
argument from the_pydecimal
backend, or to add it to the_decimal
backend even if it's unused, to resolve the incompatibility?CPython versions tested on:
3.11
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: