string issue or questions about intern

Andrew Kuchling akuchlin at mems-exchange.org
Fri Jul 14 16:56:47 EDT 2000


Brian Kelley <kelley at bioreason.com> writes:
> eval('"AAAAA"')
> eval('"AAAAB"')
> eval ('"AAAAC"')

This seems a reasonable outcome of the rule that Python always interns
string constants.  Every string gets interned, and interned strings
are never freed, so memory is constantly being consumed.  

If you need full Python expressions, there seems no way around using
eval().  But if you simply need string escapes, it's probably worth
writing a parser.  (Does such a parser already exist somewhere in the
standard library?  Anyone know?) 

--amk






More information about the Python-list mailing list