Why don't strings share data in Python?

Piet van Oostrum piet at cs.uu.nl
Wed Apr 24 08:05:05 EDT 2002


>>>>> "Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> (CG) writes:

CG> If you mean, why don't substrings share space with parent strings,
CG> hmm, that's an interesting question.  I can see that a string object
CG> implemented something like this struct:

CG>     struct ExampleString {
CG>         int len;
CG>         char *buf;
CG>     }

CG> would allow that, and it sounds like an interesting optimization. 

But it would make garbage collection harder.
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum at hccnet.nl



More information about the Python-list mailing list