Why don't strings share data in Python?
Mike Coleman
mkc+dated+1021521407.f909ec at mathdogs.com
Tue Apr 16 00:01:04 EDT 2002
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. So, for example, the space behavior of this code could be linear
rather than quadratic/horrific:
d = {}
for i in xrange(100000000):
d[mybigstring[i:]] = mybigstring[i:]
Mike
More information about the Python-list
mailing list