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-106078: Convert `_decimal` types to heap types by CharlieZhao95 · Pull Request #106079 · python/cpython

Conversation

@CharlieZhao95

@CharlieZhao95 CharlieZhao95 commented Jun 25, 2023 •
edited by bedevere-bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor
  • Establish a global module state
  • Convert _decimal types to heap types

Co-authored-by: Erlend E. Aasland [email protected]

  • Issue: Isolate the _decimal extension module #106078

Sorry, something went wrong.

Uh oh!

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

All reactions
CharlieZhao95 added 2 commits June 25, 2023 16:26
@CharlieZhao95
Move static type object to global state
978e602
Co-authored-by: Erlend E. Aasland [email protected]
@CharlieZhao95
Add NEWs entry
a16649b
@CharlieZhao95
CharlieZhao95 requested a review from rhettinger as a code owner June 25, 2023 09:02
@bedevere-bot bedevere-bot added the awaiting review label Jun 25, 2023
@bedevere-bot bedevere-bot mentioned this pull request Jun 25, 2023
Isolate the _decimal extension module #106078
Closed
14 tasks done
@CharlieZhao95

CharlieZhao95 commented Jun 25, 2023

Copy link
Copy Markdown
Contributor Author

cc: @kumaraditya303 @erlend-aasland

All reactions

Sorry, something went wrong.

Uh oh!

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

@rhettinger
rhettinger removed their request for review June 25, 2023 14:03
kumaraditya303
kumaraditya303 reviewed Jun 26, 2023
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2023-06-25-16-54-24.gh-issue-106078.cFnYUM.rst Resolved

Uh oh!

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

kumaraditya303
kumaraditya303 reviewed Jun 26, 2023
View reviewed changes
Comment thread Modules/_decimal/_decimal.c Resolved

Uh oh!

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

kumaraditya303
kumaraditya303 reviewed Jun 26, 2023
View reviewed changes
Comment thread Modules/_decimal/_decimal.c Resolved

Uh oh!

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

kumaraditya303
kumaraditya303 reviewed Jun 26, 2023
View reviewed changes

@kumaraditya303 kumaraditya303 left a comment

Copy link
Copy Markdown
Contributor

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.

Mostly LGTM but there are some compiler warnings to be taken care of.

Sorry, something went wrong.

Uh oh!

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

All reactions
@kumaraditya303 kumaraditya303 added skip news extension-modules C modules in the Modules dir labels Jun 26, 2023
CharlieZhao95 added 2 commits June 26, 2023 16:23
@CharlieZhao95
Remove news entry
3b4e823
@CharlieZhao95
Add Py_DEBUG
bb4e191
@kumaraditya303 kumaraditya303 added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 26, 2023
@bedevere-bot

bedevere-bot commented Jun 26, 2023

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @kumaraditya303 for commit bb4e191 🤖

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 26, 2023
erlend-aasland
erlend-aasland reviewed Jun 26, 2023
View reviewed changes
Comment thread Modules/_decimal/_decimal.c Resolved

Uh oh!

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

Comment thread Modules/_decimal/_decimal.c Resolved

Uh oh!

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

Comment thread Modules/_decimal/_decimal.c Resolved

Uh oh!

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

Comment thread Modules/_decimal/_decimal.c Resolved

Uh oh!

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

Comment thread Modules/_decimal/_decimal.c Resolved

Uh oh!

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

Comment thread Modules/_decimal/_decimal.c Resolved

Uh oh!

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

Comment thread Modules/_decimal/_decimal.c Resolved

Uh oh!

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

Comment thread Modules/_decimal/_decimal.c Resolved

Uh oh!

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

CharlieZhao95 and others added 7 commits June 27, 2023 14:12
@CharlieZhao95 @erlend-aasland
Update Modules/_decimal/_decimal.c
3f44aed
Co-authored-by: Erlend E. Aasland <[email protected]>
@CharlieZhao95 @erlend-aasland
Update Modules/_decimal/_decimal.c
eb9d17f
Co-authored-by: Erlend E. Aasland <[email protected]>
@CharlieZhao95 @erlend-aasland
Update Modules/_decimal/_decimal.c
4faa645
Co-authored-by: Erlend E. Aasland <[email protected]>
@CharlieZhao95 @erlend-aasland
Update Modules/_decimal/_decimal.c
531bf03
Co-authored-by: Erlend E. Aasland <[email protected]>
@CharlieZhao95
Apply erlend's comments
f445ab7
@CharlieZhao95
Change CREATE_TYPE param style
ac05050
@CharlieZhao95
Modify GLOBAL_STATE() statement position
78bf615
@erlend-aasland

erlend-aasland commented Jun 27, 2023

Copy link
Copy Markdown
Contributor

Can you please add tests for basic type qualities:

  • immutability
  • disallow instantiation
CharlieZhao95 reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

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

@kumaraditya303

kumaraditya303 commented Jun 28, 2023

Copy link
Copy Markdown
Contributor

Refleaks looks good:

0:00:00 load avg: 2.73 Run tests sequentially
0:00:00 load avg: 2.73 [1/1] test_decimal
beginning 6 repetitions
123456
......

== Tests result: SUCCESS ==

1 test OK.

Total duration: 26.0 sec
Tests result: SUCCESS
erlend-aasland and CharlieZhao95 reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

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

@CharlieZhao95
Add test cases
b6e50c4
erlend-aasland
erlend-aasland reviewed Jun 28, 2023
View reviewed changes
Comment thread Lib/test/test_decimal.py Resolved

Uh oh!

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

@CharlieZhao95

CharlieZhao95 commented Jun 28, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor Author

I found another interesting problem while testing. The following code will causes a segmentation fault:

>>> import decimal
>>> tp = type(decimal.Context().flags)  # SignalDict type
>>> tp()  # Segmentation fault

I guess that the problem is caused by accessing the wild pointer when executing the signaldict_repr function. But this problem is not caused by this PR. I tested version Python 3.10 on Linux, and this problem exists as well. Maybe this problem is worth to open a new issue.

erlend-aasland reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@CharlieZhao95
Fix lint
514c839
serhiy-storchaka
serhiy-storchaka reviewed Jun 28, 2023
View reviewed changes

@serhiy-storchaka serhiy-storchaka 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.

There are currently two test classes for the C implementation: CWhitebox and SignatureTest. None of them are suitable for new tests?

Sorry, something went wrong.

Uh oh!

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

CharlieZhao95 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@erlend-aasland

erlend-aasland commented Jun 28, 2023

Copy link
Copy Markdown
Contributor

There are currently two test classes for the C implementation: CWhitebox and SignatureTest. None of them are suitable for new tests?

Good point; I think the added tests can fit in the CWhitebox test case.

CharlieZhao95 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@CharlieZhao95
Move tests to CWhitebox
92a4c5f
kumaraditya303
kumaraditya303 reviewed Jun 29, 2023
View reviewed changes
Comment thread Modules/_decimal/_decimal.c Resolved

Uh oh!

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

kumaraditya303
kumaraditya303 approved these changes Jun 29, 2023
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting review labels Jun 29, 2023
kumaraditya303 added 2 commits June 29, 2023 12:42
@kumaraditya303
Update Modules/_decimal/_decimal.c
9e595e0
@kumaraditya303
Merge branch 'main' into isolate-decimal-part1
2f4f538
@kumaraditya303

kumaraditya303 commented Jun 29, 2023

Copy link
Copy Markdown
Contributor

I'll merge this later today after a refleak test.

CharlieZhao95 reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

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

@kumaraditya303 kumaraditya303 added the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Jun 29, 2023
@bedevere-bot

bedevere-bot commented Jun 29, 2023

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @kumaraditya303 for commit 2f4f538 🤖

If you want to schedule another build, you need to add the 🔨 test-with-refleak-buildbots label again.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot removed the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Jun 29, 2023
@kumaraditya303 kumaraditya303 self-assigned this Jun 29, 2023
@erlend-aasland

erlend-aasland commented Jun 29, 2023

Copy link
Copy Markdown
Contributor

I'll merge this later today after a refleak test.

@kumaraditya303, let me amend the tests before merging.

kumaraditya303 and CharlieZhao95 reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

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

@serhiy-storchaka

serhiy-storchaka commented Jun 29, 2023 •
edited by erlend-aasland
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

It would be nice to wait until #1062091 be merged.

Footnotes

  1. Amended with correct link by Erlend ↩

erlend-aasland and CharlieZhao95 reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

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

erlend-aasland added 2 commits June 29, 2023 11:58
@erlend-aasland
Pull in main
a3df27a
@erlend-aasland
Match existing style in test_decimal.py
883c4f1
@erlend-aasland
erlend-aasland enabled auto-merge (squash) June 29, 2023 10:10
erlend-aasland
erlend-aasland approved these changes Jun 29, 2023
View reviewed changes
@erlend-aasland
erlend-aasland merged commit fb0d9b9 into python:main Jun 29, 2023
@bedevere-bot bedevere-bot removed the awaiting merge label Jun 29, 2023
@erlend-aasland

erlend-aasland commented Jun 29, 2023

Copy link
Copy Markdown
Contributor

Good job, @CharlieZhao95!

CharlieZhao95 and mokko reacted with hooray emoji
All reactions
  • 🎉 2 reactions

Sorry, something went wrong.

Uh oh!

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

@CharlieZhao95

CharlieZhao95 commented Jun 29, 2023

Copy link
Copy Markdown
Contributor Author

Good job, @CharlieZhao95!

Thanks all! Let's move on to the next! :)

All reactions

Sorry, something went wrong.

Uh oh!

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

@skirpichev skirpichev mentioned this pull request Feb 10, 2026
Speed regression in the decimal module due to using heap types #144650
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@serhiy-storchaka serhiy-storchaka serhiy-storchaka left review comments
@erlend-aasland erlend-aasland erlend-aasland approved these changes
@kumaraditya303 kumaraditya303 kumaraditya303 approved these changes

Uh oh!

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

Assignees

@kumaraditya303 kumaraditya303

Labels

extension-modules C modules in the Modules dir skip news

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.

5 participants

@CharlieZhao95 @bedevere-bot @erlend-aasland @kumaraditya303 @serhiy-storchaka
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 01402520 — 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.