d3/d3-array

Adopt InternMap for d3.group et al.?

mbostock opened this issue · 4 comments

Should d3.group, d3.rollup, et al. return an InternMap instead of a regular Map? That would allow you to group by date easily. I think we can even consider it backwards-compatible since the behavior is the same for primitives and for objects that do not implement object.valueOf (which is most things besides Date and the rarely-used Number, String, and Boolean).

Possibly, ordinal scales could use an InternMap instead of stringifying domain values (see band.domain for example). Though that would definitely merit a major version bump since the domain values would no longer be strings. Actually, it should be backwards-compatible for date, since the internal strings are not exposed; however, if custom objects that implement toString instead of valueOf are used, it wouldn’t be backwards-compatible.

I'd be curious to see a before and after example of grouping by dates.

I wonder what the current most common pattern is for grouping by dates.

Also curious what the potential performance impact is for the additional function invocations (the internal calls to intern_get, intern_set, etc. in the context of operations on large arrays).

Probably negligible but would be interesting to see benchmarks.

@curran See the notebook linked in the PR for examples.