Skip to content

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions