Skip to content

Support copy.replace() for decimal.Context #155041

Closed

Description

@serhiy-storchaka

Feature or enhancement

There is no easy way to get a copy of a decimal.Context with some fields changed: Context.copy() takes no arguments, and the Context constructor takes unspecified fields from DefaultContext, not from an existing context.

I propose to support copy.replace():

ctx = copy.replace(decimal.getcontext(), prec=50)

Fields which are not specified keep the values they have in the original context. As in the constructor, flags and traps can be specified as a list of signals.

Linked PRs

Activity

  1. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Aug 1, 2026
  2. added a commit that references this issue on Aug 2, 2026
  3. added a commit that references this issue on Aug 14, 2026
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

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions