new string method in 2.5 (partition)
Fredrik Lundh
fredrik at pythonware.com
Thu Sep 21 04:01:32 EDT 2006
Irmen de Jong wrote:
> Because the result of partition is a non mutable tuple type containing
> three substrings of the original string, is it perhaps also the case
> that partition works without allocating extra memory for 3 new string
> objects and copying the substrings into them?
nope. the core string type doesn't support sharing, and given the
typical use cases for partition, I doubt it would be more efficient
than actually creating the new strings.
(note that partition reuses the original string and the separator,
where possible)
(and yes, you're not the first one who thought of this. check the
python-dev archives from May this year for more background).
</F>
More information about the Python-list
mailing list