Why don't strings share data in Python?

Erno Kuusela erno-news at erno.iki.fi
Tue Apr 16 05:41:09 EDT 2002


In article <87d6x09trz.fsf at mathdogs.com>, Mike Coleman
<mkc+dated+1021521407.f909ec at mathdogs.com> writes:

| Does anyone know why strings (i.e., those of length >1) don't share
| their data in Python?  Since their immutable, it seems like this
| would be the obvious thing to do.

in addition to reasons presented i other replies, this would
also result in much less obvious memory usage. saving a short
slice of a huge string would hang on to the huge string. java
does this, and i've heard people make less than flattering
comments about this feature.

  -- erno



More information about the Python-list mailing list