isi-vista / immutablecollections

A library for immutable collections, in the spirit of Guava's Immutable Collections.
MIT License
3 stars 2 forks source link

Provide ImmutableDict & ImmutableMultiDict factory methods which ban duplicate additions #53

Closed qpwo closed 5 years ago

qpwo commented 5 years ago

Branching off #49, in what manner should duplicates be banned from dicts and multidicts?

Some potential options:

I'm assuming we want both a new constructor and a new kwarg for each data type. Something like constructor immutabledict_from_unique_BLANK() and kwarg forbid_duplicate_BLANK where BLANK is either keys or items.

gabbard commented 5 years ago

From past experience, there are situations when you would want to raise an exception in either of the last two cases; I have not encountered a situation where the first option is useful.