Title: Python implementation of Decimal can hang in floor division · Issue #140036 · python/cpython · GitHub
Open Graph Title: Python implementation of Decimal can hang in floor division · Issue #140036 · python/cpython
X Title: Python implementation of Decimal can hang in floor division · Issue #140036 · python/cpython
Description: Bug report # import decimal import _pydecimal as decimal _unbounded_dec_context = decimal.getcontext().copy() _unbounded_dec_context.prec = decimal.MAX_PREC _unbounded_dec_context.Emax = decimal.MAX_EMAX _unbounded_dec_context.Emin = dec...
Open Graph Description: Bug report # import decimal import _pydecimal as decimal _unbounded_dec_context = decimal.getcontext().copy() _unbounded_dec_context.prec = decimal.MAX_PREC _unbounded_dec_context.Emax = decimal.MA...
X Description: Bug report # import decimal import _pydecimal as decimal _unbounded_dec_context = decimal.getcontext().copy() _unbounded_dec_context.prec = decimal.MAX_PREC _unbounded_dec_context.Emax = decimal.MA...
Opengraph URL: https://github.com/python/cpython/issues/140036
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Python implementation of Decimal can hang in floor division","articleBody":"# Bug report\n\n```py\n# import decimal\nimport _pydecimal as decimal\n\n_unbounded_dec_context = decimal.getcontext().copy()\n_unbounded_dec_context.prec = decimal.MAX_PREC\n_unbounded_dec_context.Emax = decimal.MAX_EMAX\n_unbounded_dec_context.Emin = decimal.MIN_EMIN\n_unbounded_dec_context.traps[decimal.Inexact] = 1 # sanity check\ndecimal.setcontext(_unbounded_dec_context)\n\nx = decimal.Decimal('1')\ny = x // 1\n```\n\nThe C implementation evaluates the last line instantly, but the Python implementation hangs for a long time (infinitely?). The modulus operation has the same behavior.\n\ncc @tim-one\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-140044\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/serhiy-storchaka","@type":"Person","name":"serhiy-storchaka"},"datePublished":"2025-10-13T11:25:56.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":38},"url":"https://github.com/140036/cpython/issues/140036"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:70d542a3-dd17-335e-6b0c-e4996c0b9800 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BF58:15EF46:D9A5D0:13B53DA:6A5752DD |
| html-safe-nonce | 69ab9a2b6045dca4872a748850865c6c3aa1e4bc6889a202f34794e9e8631145 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRjU4OjE1RUY0NjpEOUE1RDA6MTNCNTNEQTo2QTU3NTJERCIsInZpc2l0b3JfaWQiOiIzMTc5NDA5OTY4NTQyOTk1MTY1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3b703b40b464e28f6b65162e7c6ecb9f46de580f368f4448a1844c51ba5b9b0f |
| hovercard-subject-tag | issue:3509658216 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/140036/issue_layout |
| twitter:image | https://opengraph.githubassets.com/19445d7531c32be1be264b099480c71c1327bcca7fe0d254b5d865cb67321c3a/python/cpython/issues/140036 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/19445d7531c32be1be264b099480c71c1327bcca7fe0d254b5d865cb67321c3a/python/cpython/issues/140036 |
| og:image:alt | Bug report # import decimal import _pydecimal as decimal _unbounded_dec_context = decimal.getcontext().copy() _unbounded_dec_context.prec = decimal.MAX_PREC _unbounded_dec_context.Emax = decimal.MA... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | serhiy-storchaka |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4e7a7296a3830877cf21a6ad2a972c9e618a48915e03966cf0c53eb08e5aad98 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 602250ea3b6dd8302a7220ef98adb828dbc807e4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width