Skip to content

reflect: add a range like interface for Value #11104

@minux

Description

@minux

The current reflect.Value interface for traversing maps requires allocating
all the keys at once (reflect.Value.MapKeys), which is not efficient for
huge maps.

Additionally, as floating point NaNs are never equal to each other, the
current interface makes it impossible to get the value for NaN keys.

We can introduce this

func (v Value) MapKeyValues() [][2]Value

to solve the NaN problem, but I'm more interested in the first problem.

Actually, if we decide to introduce a range like operation on reflect.Value,
I think we should make it work for other range-able types (channels,
arrays, strings and slices) too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions