[Python-3000] Immutable bytes type and dbm modules

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Aug 8 02:26:22 CEST 2007


Nick Coghlan wrote:
> I would 
> expect the situation to be the same as with sets - you'd use the mutable
> version by default, unless there was some specific reason to want the 
> frozen version (usually because you want something that is hashable, or 
> easy to share safely amongst multiple clients).

My instinct with regard to sets is the other way around,
i.e. use immutable sets unless there's a reason they
need to be mutable. The reason is safety -- accidentally
trying to mutate an immutable object fails more quickly
and obviously than the converse.

If Python had had both mutable and immutable strings
from the beginning, would you be giving the same
advice, i.e. use mutable strings unless they need to
be immutable? If not, what makes strings different from
sets in this regard?

--
Greg


More information about the Python-3000 mailing list