Skip to content

Feature request: Intermediate API for updating collections, especially AbstractDict #31199

@chethega

Description

@chethega

One of the most common operations on AbstractDict is updating values in-place, like e.g. d[k] += v or haskey(d, k) ? d[k]+= v : d[k] = v.

It is unlikely that user-code with that idiom will ever get optimized to perform only a single look-up, and previous discussions got stalled on what is the preferred user-facing API.

I propose to introduce a new un-exported but stable and documented intermediate API. Design goal is maximal flexibility, at the cost of arbitrary uglyness. Then, package authors who implement an AbstractDict can specialize this intermediate API to accelerate updates, and package authors who use AbstractDict can implement their favorite beautiful user-facing API that uses the intermediate API.

edit: Excised preliminary proposal to separate comment. If you vote on the issue, use this comment for expressing feelings about the general idea of an intermediate ugly API and the below comment for expressing feelings about the specific preliminary proposal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    collectionsData structures holding multiple items, e.g. sets

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions