Message58081
| Author |
skip.montanaro |
| Recipients |
skip.montanaro |
| Date |
2007年12月02日.07:51:01 |
| SpamBayes Score |
0.0014263004 |
| Marked as misclassified |
No |
| Message-id |
<1196581862.98.0.506596232577.issue1538@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
The topic of avoiding string copies in certain string methods came up in
the
ChiPy list:
http://mail.python.org/pipermail/chicago/2007-December/002975.html.
The attached patch modifies the split and rsplit implementations to
avoid
making a copy of self when the split fails to find anything to split on:
>>> s = "abc def"
>>> x = s.split(';')
>>> x[0] is s
True
>>> y = s.rsplit('-')
>>> y[0] is s
True
>>> t = "abcdef"
>>> x = t.split()
>>> x[0] is t
True
>>> y = t.rsplit()
>>> y[0] is t
True
All tests pass. Given that this is just a small optimization I
don't believe any changes to the docs or the existing tests are
necessary. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2007年12月02日 07:51:03 | skip.montanaro | set | spambayes_score: 0.0014263 -> 0.0014263004 recipients:
+ skip.montanaro |
| 2007年12月02日 07:51:03 | skip.montanaro | set | spambayes_score: 0.0014263 -> 0.0014263 messageid: <1196581862.98.0.506596232577.issue1538@psf.upfronthosting.co.za> |
| 2007年12月02日 07:51:02 | skip.montanaro | link | issue1538 messages |
| 2007年12月02日 07:51:02 | skip.montanaro | create |
|