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 — Isolate the `_decimal` extension module · Issue #106078 · python/cpython

Isolate the _decimal extension module #106078

New issue
Copy link
New issue
Copy link
Closed
Closed
Isolate the _decimal extension module#106078
Copy link
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtopic-subinterpreterstype-featureA feature request or enhancementA feature request or enhancement

Description

@CharlieZhao95
CharlieZhao95
opened on Jun 25, 2023
Issue body actions

This issue is used to track the PRs split from gh-103092. Isolate the _decimal extension module by:

  • Establish a global module state and convert static types to heap types
  • Move other global static variables to the global module state(possibly multiple PRs)
    • DecimalException
    • basic_context_template
    • tls_context_key
    • cached_context
    • current_context_var
    • default_context_template
    • extended_context_template
    • round_map
    • Rational
    • SignalTuple
    • External C-API functions
  • Convert the global module state to true module state
    • signal_map
    • cond_map
    • convert global state to module state

See original issue Isolate Stdlib Extension Modules and PEP-687 for details.

Linked PRs

  • gh-106078: Convert _decimal types to heap types #106079
  • gh-106078: Move DecimalException to global state #106301
  • gh-106078: Move context template to decimal module global state #106346
  • gh-106078: Move static objects related to CONTEXTVAR to the decimal module global state #106395
  • gh-106078: Move static variables initialized once to decimal module global state #106475
  • gh-106078: Move external C-API functions to decimal module global state #106616
  • gh-106078: Prepare to isolate decimal module #106880
  • gh-106078: Isolate decimal module #107287
  • gh-106078: Suppress the warning caused by multi-phase initialization of decimal #107524

Activity

  1. CharlieZhao95
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Jun 25, 2023
  2. erlend-aasland
    added
    topic-subinterpreters
    on Jun 25, 2023
  3. github-project-automation
    added this to Subinterpreterson Jun 25, 2023
  4. github-project-automation
    moved this to Todo in Subinterpreterson Jun 25, 2023
  5. erlend-aasland
    added
    extension-modulesC modules in the Modules dirC modules in the Modules dir
    on Jun 25, 2023
  6. erlend-aasland
    added a commit that references this issue on Jun 29, 2023

    gh-106078: Convert `_decimal` types to heap types (#106079)

    fb0d9b9
  7. erlend-aasland commented on Jun 29, 2023

    @erlend-aasland
    erlend-aasland
    on Jun 29, 2023
    Contributor
    More actions

    What is your next step, @CharlieZhao95?

  8. erlend-aasland
    moved this from Todo to In Progress in Subinterpreterson Jun 29, 2023
  9. CharlieZhao95 commented on Jun 29, 2023

    @CharlieZhao95
    CharlieZhao95
    on Jun 29, 2023
    ContributorAuthor
    More actions

    What is your next step, @CharlieZhao95?

    I think next we can move the remaining static global PyObject to global_state:

    • DecimalException
    • basic_context_template
    • current_context_var
    • default_context_template
    • extended_context_template
    • round_map
    • Rational
    • SignalTuple
    • External C-API functions

    This shouldn't be too complicated. The only question is whether we should move these external-API functions, which simply hold function pointers used by numeric types, such as nb_multiply, nb_floor_divide and so on. They will not change during the lifecycle of the program.

  10. erlend-aasland commented on Jun 29, 2023

    @erlend-aasland
    erlend-aasland
    on Jun 29, 2023
    Contributor
    More actions

    Pick the low-hanging fruit first. It is better with multiple small PRs than one big.

    Reacted by Charlie Zhao and Alex Waygood
  11. CharlieZhao95 commented on Jun 29, 2023

    @CharlieZhao95
    CharlieZhao95
    on Jun 29, 2023
    ContributorAuthor
    More actions

    Pick the low-hanging fruit first. It is better with multiple small PRs than one big.

    Okay! let's go step by step. I will put the objects listed above into multiple small PRs.

    Reacted by Erlend E. Aasland
  12. erlend-aasland
    added a commit that references this issue on Jul 2, 2023

    gh-106078: Move DecimalException to _decimal state (#106301)

    dbefa88
  13. carljm
    added a commit that references this issue on Jul 3, 2023

    Merge branch 'main' into modulelocals

    ac11740
  14. kumaraditya303
    added 4 commits that reference this issue on Jul 3, 2023

    gh-106078: Move `context template` to decimal module global state (#1…

    bf06c68

    gh-106078: Move static objects related to `CONTEXTVAR` to the decimal…

    1c9e493

    gh-106078: Move static variables initialized once to decimal module g…

    9384665

    gh-106078: Move external C-API functions to decimal module global sta…

    e5c32a8
  15. CharlieZhao95 commented on Jul 11, 2023

    @CharlieZhao95
    CharlieZhao95
    on Jul 11, 2023
    ContributorAuthor
    More actions

    The second stage has been completed. All documented static variables are moved to the global state. Thanks for review! @erlend-aasland @kumaraditya303

    Based on the experience of the original PR, we should also move the signal_map into the module state before converting the global state. This array of structures contains potentially global variables(ex).

    typedef struct {
        const char *name;   /* condition or signal name */
        const char *fqname; /* fully qualified name */
        uint32_t flag;      /* libmpdec flag */
        PyObject *ex;       /* corresponding exception */
    } DecCondMap;
    
    static DecCondMap signal_map[] = {
        ...
    }

    IMO, the next stage should be:

    1. Move signal_map to global state
    2. Convert the global module state to true module state

    How about opening a draft PR (convert the global module) first? This will allow us to see failed test cases raised by signal_map more clearly. Or do I just start moving signal_map into global state?

  16. erlend-aasland commented on Jul 11, 2023

    @erlend-aasland
    erlend-aasland
    on Jul 11, 2023
    Contributor
    More actions

    How about opening a draft PR (convert the global module) first? This will allow us to see failed test cases raised by signal_map more clearly. Or do I just start moving signal_map into global state?

    FTR, I often open PRs on my own fork to check CI issues, so that I won't pollute the CPython PR list too much.

    Also: I'll be away for the rest of summer, so my response time will probably be slower than usual, just so you know :)

    Reacted by Charlie Zhao
  17. CharlieZhao95 commented on Jul 14, 2023

    @CharlieZhao95
    CharlieZhao95
    on Jul 14, 2023 · Hidden as outdated
    Author
    show commentMore actions
  18. kumaraditya303
    added a commit that references this issue on Jul 20, 2023

    gh-106078: Prepare to isolate decimal module (#106880)

    a1620dd
  19. kumaraditya303
    added a commit that references this issue on Jul 28, 2023

    gh-106078: Isolate `decimal` module (#107287)

    a43cc3f
  20. erlend-aasland commented on Jul 28, 2023

    @erlend-aasland
    erlend-aasland
    on Jul 28, 2023
    Contributor
    More actions

    Great work, @CharlieZhao95 and @kumaraditya303!

    Reacted by Charlie Zhao, Kumar Aditya and Kirill Podoprigora
  21. kumaraditya303
    closed this as completedon Jul 29, 2023
  22. github-project-automation
    moved this from In Progress to Done in Subinterpreterson Jul 29, 2023
  23. AlexWaygood
    added a commit that references this issue on Oct 6, 2023

    gh-106078: Suppress the warning caused by multi-phase initialization …

    de10522
  24. Glyphack
    added a commit that references this issue on Sep 2, 2024

    pythongh-106078: Suppress the warning caused by multi-phase initializ…

    56a89cb
  25. benoitc
    added a commit that references this issue on Mar 23, 2026

    Require Python 3.14+ for OWN_GIL mode

    ba5f4fe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirC modules in the Modules dirtopic-subinterpreterstype-featureA feature request or enhancementA feature request or enhancement

    Projects

    • Subinterpreters
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — 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.